Printing one record

andymac

Registered User.
Local time
Today, 18:00
Joined
Jun 2, 2013
Messages
36
Hi guys,

I'm trying to get a form to print just one record on a report - and using this code:

Private Sub Command24_Click()

Dim strReportName As String
Dim strCriteria As String

strReportName = "Badge"
strCriteria = "[ID]='" & Me![ID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

End Sub

It won't work though - says there's a 'data type mis-match in criteria expression'

Any thoughts?

Thanks

Andrew
 
If the ID is Number type do not enclose them in between single quotes..
 
Thanks for quick reply,

You've lost me - where have I typed something wrong? Sorry - I'm not very apt at reading code!

Andrew
 
Code:
Private Sub Command24_Click()
    Dim strReportName As String
    Dim strCriteria As String
    strReportName = "Badge"
    strCriteria = [COLOR=Red][B]"[ID]=" & Me![ID][/B][/COLOR]
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub
 

Users who are viewing this thread

Back
Top Bottom