Print current record

saintsman

Registered User.
Local time
Today, 00:50
Joined
Oct 12, 2001
Messages
138
I am trying to print a report of the current record in a form.

From the Help files I have found this:

Tip You can print a form's current record in a report by carrying out the OpenReport action in the Click event procedure for a command button. For example, adding the following Visual Basic for Applications code to the Click event procedure for a command button on an Orders form prints the current record in the Invoice report:

Dim strDocName As String
Dim strFilter As String
strDocName = "Invoice"
strFilter = "OrderID = Forms!Orders!OrderID"
DoCmd.OpenReport DocName, acViewNormal, , strFilter

However, when I use it (Report and Form names changed to my requirements) I get a syntax error (missing operator) in query expression (OrderID = Forms!Orders!OrderID)

VBA is not my strong point. Where am I going wrong?

Thanks in advance.
 
Hi

It's far easier to put the criteria in the underlying query of your report. So let's say the name of your field on your form was OrderID, in the criteria for that field in your query you would put

=[Forms]![yourFormNameInHere]![OrderID]

This will work when you open your report form your form

HTH
Rob
 
Rob,

Thank You - Proper Job!
 

Users who are viewing this thread

Back
Top Bottom