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.
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.