From: jlute on
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!!!
From: Allen Browne on
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))

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<jlute(a)marzetti.com> wrote in message
news:427806df-6c90-46af-a944-66a677491d56(a)k37g2000hsf.googlegroups.com...
> 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!!!

From: jlute on
Please disregard. I got it with:

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