Printing a report without Entering Order No

N

Nick Bradbury

Hi

I have several reports that when the print button is pressed a message box
appears asking for the OrderNo to be entered. I know this is because of the
underlying query but I want to know how to print the report for the Order
that is currently displayed on screen without having to enter it manually.

Thanks

Nick
 
D

Duane Hookom

I try to avoid using any dynamic criteria ( parameter prompts or references
to controls on forms) in the record sources of my reports. Try to use the
Where Condition in the DoCmd.OpenReport method. For instance:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtPrimaryKey) Then
strWhere = strWHere & " And [PKField] = " & _
Me.txtPrimaryKey
End If
DoCmd.OpenReport "rptName", acPreview, , strWhere

You can build lots of criteria into the Where Condition with code like this
and don't have to be "tied" to a specific form or parameter prompt.
 

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