Opening Report 2 Where Conditions

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?
 
K

Klatuu

The And needs to be inside the quotes:
DoCmd.OpenReport "rptBoxPrintout", acViewPreview, , "TestID= " & Me.TestID
& " And BoxNumber = " & Me.BoxNumber
 
S

Stuart McCall

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)
 

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

Similar Threads


Top