syntax error missing operator

  • Thread starter Thread starter jlute
  • Start date Start date
J

jlute

I'm getting this error and it's regarding this:

DoCmd.OpenReport "rptPKWeightCalculatorASSsFGs", acPreview, , _
"[PKWTID] = " & Me!PKWTID

The problem is that values in [PKWTID] can contain non-alphanumeric
characters, underscores, etc. such as:

PKWT100050_6/12FLOZBTGLCLPLLAPAPER

The underscore and the front slash trigger the error.

What can I change in the code to relieve this?

Thanks in advance!!!
 
Please disregard. I got it with:

Dim stDocName As String
Dim strWhere As String
strWhere = "[PKWTID] = """ & _
Forms![frmQueryPKWTCalcsFGs]![PKWTID] & """"
DoCmd.OpenReport "rptPKWeightCalculatorASSsFGs", acPreview _
, , strWhere
 
If you open your table in design view, what is the Data Type of the PKWTID
field?

If Text, try:
DoCmd.OpenReport "rptPKWeightCalculatorASSsFGs", acViewPreview, , _
"[PKWTID] = """ & Me!PKWTID & """

If Number, try:
DoCmd.OpenReport "rptPKWeightCalculatorASSsFGs", acViewPreview, , _
"[PKWTID] = " & Val(Nz(Me!PKWTID, 0))
 
Back
Top