Printing a report from a form with Open Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm new to programming in Access and am not a programmer by any means. But I have a problem with the following code. I'm sure that it is something basic with the naming convention. I get an error that says "Invalid bracketing of name". Can somebody set me straight

Thank

MS Access 97 - This is on click code that is to print a report from a form that is compiled information from 3 tables

Dim sSQL As Strin
DoCmd.RunCommand acCmdSaveRecord 'Saves the record so it is available to print even if it was just added right no
sSQL = Me.[PO Number
DoCmd.RunCommand acCmdSaveRecor
DoCmd.OpenReport "Purchase Order", acViewPreview, , "[PO Info.PO Number] =" & sSQ
 
Walt said:
I'm new to programming in Access and am not a programmer by any means.
But I have a problem with the following code. I'm sure that it is
something basic with the naming convention. I get an error that says
"Invalid bracketing of name". Can somebody set me straight?
Thanks


MS Access 97 - This is on click code that is to print a report from a
form that is compiled information from 3 tables.
Dim sSQL As String
DoCmd.RunCommand acCmdSaveRecord 'Saves the record so it is available
to print even if it was just added right now
sSQL = Me.[PO Number]
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Purchase Order", acViewPreview, , "[PO Info.PO
Number] =" & sSQL

Brackets don't go around the combination of table-dot-field as you have
above. You also need quotes around your variable since it is a string.

DoCmd.OpenReport "Purchase Order", acViewPreview, , "[PO Info].[PO Number]
='" & sSQL & "'"
 
Back
Top