syntax error missing operator

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!!!
 
J

jlute

Please disregard. I got it with:

Dim stDocName As String
Dim strWhere As String
strWhere = "[PKWTID] = """ & _
Forms![frmQueryPKWTCalcsFGs]![PKWTID] & """"
DoCmd.OpenReport "rptPKWeightCalculatorASSsFGs", acPreview _
, , strWhere
 
A

Allen Browne

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))
 

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