Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenReport with 2 and + criterias...

Status
Not open for further replies.

jondion80

Programmer
Jun 21, 2002
7
0
0
CA
Hi everybody!
Why does this line is ok
DoCmd.OpenReport "test1", acViewPreview, , "[C07-CODE]=forms!Formulaire1!criter_code.value"

And that this line makes a report with no data?

DoCmd.OpenReport "test1", acViewPreview, , "[C07-CODE]=forms!Form2!criter_code.value" AND [C16-VEND]=forms!Form2!criter_vend.value"

It seems that it's hard to put more than one criteria at the same time. Thanks for your help!
 
You've got an extra quote mark. Try this:

DoCmd.OpenReport "test1", acViewPreview, , "[C07-CODE]=forms!Form2!criter_code.value AND [C16-VEND]=forms!Form2!criter_vend.value"

Another thing you need to check are the field types. This is ok if [C16-VEND] and [C07-CODE] are both numbers, but will fail if they are text values.

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Thanks Ben,
Well the extra quote was a copy/paste error :(
About the two fields, both are text values. What's wrong with this and how can I can expect to solve my problem? Thanks again.
 
Personally I would concatenate the form values into the statement so:

DoCmd.OpenReport "test1", acViewPreview, , "[C07-CODE]='" & forms!Form2!criter_code.value & "' AND [C16-VEND]='" & forms!Form2!criter_vend.value & "'"

HTH


Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top