Docmd.OpenReport WhereCondition grief

  • Thread starter Thread starter G
  • Start date Start date
G

G

I am trying to use a command button on a form call up a report that is based
a query that requires one parameter [RMA NO] using docmd.OpenReport.

I want to pass the value of a field, RMA NO, on the form as the parameter
value.

The problem is that I run into a syntax error message or it just ignores the
where condition all together and brings up the criteria prompt from the
query design.

Any ideas

HERE IS THE CODE:
Dim stDocName As String 'variable to hold the Travel Card report name
Dim strCriteria As String 'variable to hold the RMA NO to pass to the
warranty repair table query

'use the first 8 chars of the part number in the form and call the
'TravelCardtoPrint Procedure
stDocName = TravelCardToPrint(Left(Me("Part Number"), 8))

strCriteria = "[RMA NO]=" & Forms![Warranty Repair Form]![RMA NO]

DoCmd.OpenReport stDocName, acPreview, ,strCriteria
 
If the query is designed to ask for a parameter, then it will do so.
Can you remove the parameter, or have the query read the value from the
form?

The syntax error might be related to the data type of RMA No. If it is a
Text type field, you need extra quotes:
strCriteria = "[RMA NO]=""" & Forms![Warranty Repair Form]![RMA NO] & """"
 
Back
Top