Opening Report 2 Where Conditions

  • Thread starter Thread starter Ripper
  • Start date Start date
R

Ripper

I am using the following code to open a report. There are 2 where
conditions. Both work fine if I just use 1. When I put them together with
AND I get a type mismatch runtime error 13.

DoCmd.OpenReport "rptBoxPrintout", acViewPreview, , "TestID=" & Me.TestID
And "BoxNumber =" & Me.BoxNumber

TestID and BoxNumber are both numbers.

What am I doing wrong?
 
The And needs to be inside the quotes:
DoCmd.OpenReport "rptBoxPrintout", acViewPreview, , "TestID= " & Me.TestID
& " And BoxNumber = " & Me.BoxNumber
 
Ripper said:
I am using the following code to open a report. There are 2 where
conditions. Both work fine if I just use 1. When I put them together
with
AND I get a type mismatch runtime error 13.

DoCmd.OpenReport "rptBoxPrintout", acViewPreview, , "TestID=" & Me.TestID
And "BoxNumber =" & Me.BoxNumber

TestID and BoxNumber are both numbers.

What am I doing wrong?

The And keyword needs to be embedded in the criteria string:

DoCmd.OpenReport "rptBoxPrintout", acViewPreview, , _
"TestID=" & Me.TestID & "And BoxNumber =" & Me.BoxNumber

(I've split the line to escape mail system word wrap)
 
Back
Top