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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print current record button

Status
Not open for further replies.

nflutter

Technical User
Aug 7, 2005
34
GB
Trying to print the current record to a report. Keep getting syntax error message. Heres the code, any help appreciated.

Private Sub Command49_Click()
On Error GoTo Err_Command49_Click

Dim strWhere As String
strWhere = "Contact ID='" & Me.ContactID & "'"
DoCmd.OpenReport "Label", acPreview, , strWhere

Exit_Command49_Click:
Exit Sub

Err_Command49_Click:
MsgBox Err.Description
Resume Exit_Command49_Click

End Sub

Thanks
 
Since people search these forums looking for help with similiar problems, proper etiquette requires that when posters solve problems on their own, they post the resolution.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I thought I had a problem with the quotes and double quotes around the Me.ContactID value because it was an integer value etc..... but far more stupid error! I had a space in field Contact ID, should have been ContactID NO SPACE! Heres my full code for the button and it works fine now.

Private Sub Command49_Click()
On Error GoTo Err_Command49_Click

Dim strWhere As String
strWhere = "ContactID=" & Me.ContactID
DoCmd.OpenReport "Label", acPrint, , strWhere

Exit_Command49_Click:
Exit Sub

Err_Command49_Click:
MsgBox Err.Description
Resume Exit_Command49_Click

End Sub

Tks for looking, hope this helps you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top