View Full Version : Passing value to open report


Friday
02-26-2004, 01:31 PM
Can anyone see what's wrong with this code?
+++++++++++++++++++++++++++++++++
Private Sub Command22_Click()
Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "rptindvAudit"
stLinkCriteria = "fldAuditNumber =" & Me.txtAuditNumber


DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria


End Sub
+++++++++++++++++++++++++++++++++
When the button is clicked, I get prompted for a value:
(see parm_error.jpg)
When I hover the mouse over the code the values are correct.
(see parm_error2.jpg)
The data source for the report is a query with no prompts built in. I run this same exact code on another form and it works fine. The only difference is on that example I am matching a value to a key field. In the above code, neither field is a key value. I am running AccessXP on an XP machine. Has anyone ran into this before?

Rich
02-26-2004, 01:49 PM
try
stLinkCriteria = "fldAuditNumber =" & "'" & Me![txtAuditNumber] & "'"

Friday
02-26-2004, 01:54 PM
Never Mind! Got It! Changed the matching values to the record ID and it works fine. Don't know why it won't work on another field, but... :D

Friday
02-27-2004, 05:16 PM
Thanks, Rick. I'll try your suggestion. I want to match on the Audit Number value on another report if I can. :cool: