Report from a Parameterized Query

B

Bob Mullen

I have a report generated from a parameterized query. I want to print the from a form and pass the parameter to the report from information on the form rather than prompting the user

I hope I have been clear enough to enable assistance. Thanks in advance.
 
A

Allen Browne

Drop the parameter from the query, and use the WhereCondition of the
OpenReport action instead.

For example, to print the record that has the same InvoiceID number as the
record in the form, put this into the event procedure of your command
button:

Private Sub cmdPrintRecord_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Make sure there is a record to print.
MsgBox "Select the record to print."
Else
strWhere = "InvoiceID = " & Me.[InvoiceID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob Mullen said:
I have a report generated from a parameterized query. I want to print the
from a form and pass the parameter to the report from information on the
form rather than prompting the user.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top