error 3464; print single record from a form in a report

G

Guest

I am trying to print a report that consists of a single record. The command
button is on the form where the single record is generated.
I went to the MS KB and found article ACC2000. The code is:
Private Sub cmdPrintRecord_Click()

Dim strReportName As String
Dim strCriteria As String

strReportName = "rptPrintRecord"
strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

End Sub
My report name is PatientRpt.
My primary key for the table (PatientTbl) is PtIDpk.
I substituted PatientRpt for rptPrintRecord and PtIDpk for CustomerID.
However, when I go to the form, click the button I receive an error message:
"Run-time error '3464':
Data type mismatch in criteria expression."
Please advise
 
A

Allen Browne

If CustomerID is a Number field (not a Text field), you don't need the extra
quotes:
strCriteria = "[CustomerID] = " & Me![CustomerID]

That could fail at a new record, or if the edits have not yet been failed.
To solve those issues, see:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
 
G

Guest

That was it. Thank you very much.
Allen Browne said:
If CustomerID is a Number field (not a Text field), you don't need the extra
quotes:
strCriteria = "[CustomerID] = " & Me![CustomerID]

That could fail at a new record, or if the edits have not yet been failed.
To solve those issues, see:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

dlazenby said:
I am trying to print a report that consists of a single record. The command
button is on the form where the single record is generated.
I went to the MS KB and found article ACC2000. The code is:
Private Sub cmdPrintRecord_Click()

Dim strReportName As String
Dim strCriteria As String

strReportName = "rptPrintRecord"
strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

End Sub
My report name is PatientRpt.
My primary key for the table (PatientTbl) is PtIDpk.
I substituted PatientRpt for rptPrintRecord and PtIDpk for CustomerID.
However, when I go to the form, click the button I receive an error
message:
"Run-time error '3464':
Data type mismatch in criteria expression."
Please advise
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top