Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing label for current record in form

Status
Not open for further replies.

doctorswamp

Technical User
Jul 15, 2003
133
GB
Hi

Nearly there following earlier help.

Want to print label for current record in a form. Have report called Labels and use this code on the form's command button.


Private Sub cmdLabel_Click()
On Error GoTo Err_cmdLabel_Click

Dim stDocName As String

stDocName = "Labels"
DoCmd.OpenReport stDocName, acPreview, , "Company=" & Me.Company

Exit_cmdLabel_Click:
Exit Sub

Err_cmdLabel_Click:
MsgBox Err.Description
Resume Exit_cmdLabel_Click

End Sub

It comes back with 'Syntax error (missing operator) in query expression '[Company = Bowes]' when on using the command button on record Bowes.

Sorry to be slow with VB, which seems hard to get into - must be plain man's guides somewhere!
 
You need to enclose text within single quotes

as

"Company=' " & Me.Company & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top