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

2 opening arguments 4
Open Form Where Condition 2
Open Report 5
combo box data type 1
Report VB Code 1
Open Report OnClick 2
Access 2010 Visible Property having no effect 1
Keep First Letters, with exceptions 0

Top