Getting Parameter Value Error when printing selected record

P

Pamela

Hi, I'm trying to print a single (current) record in my report, but I keep
getting this error. I've tried creating a filter through a query, and
creating a MyWhereCondition in the code but when I click the print command
button, it doesn't read the value. My current code (again, I've tried many
different tactics) is:

Private Sub PrintrptAssn_Click()
On Error GoTo Err_PrintrptAssn_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptAssignment", acViewPreview, , "[InspectionID] = " &
[InspectionID]

Exit_PrintrptAssn_Click:
Exit Sub

Err_PrintrptAssn_Click:
MsgBox Err.Description
Resume Exit_PrintrptAssn_Click

End Sub

Thanks so much for any help!!
 
D

Duane Hookom

Your code assumes InspectionID is numeric. If it isn't, you need to use:
DoCmd.OpenReport "rptAssignment", acViewPreview, , "[InspectionID] = """ &
[InspectionID] & """"
 

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