Where condition on reports doesn't work when passing parameter from the forms

O

oranmeir

DoCmd.OpenReport stDocName, acPreview, , "[ORDERID] =
Forms![OrderForm].[ORDERID]"

On access 2003 only the orderid selected on the form shown on the
report. on access 2007, all the records shows on the report. it ignore
the where condition...

Any ideas?
 
A

Allen Browne

Concatenate the value from the from into the WhereCondition string:
DoCmd.OpenReport stDocName, acViewPreview, , _
"[ORDERID] = " & Forms![OrderForm].[ORDERID]

There's a couple of other things that can go wrong here, such as if the
record in the form is not saved, or if the form is at a new record. See:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
 
O

oranmeir

Same problem... anyone?

Allen said:
Concatenate the value from the from into the WhereCondition string:
DoCmd.OpenReport stDocName, acViewPreview, , _
"[ORDERID] = " & Forms![OrderForm].[ORDERID]

There's a couple of other things that can go wrong here, such as if the
record in the form is not saved, or if the form is at a new record. See:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DoCmd.OpenReport stDocName, acPreview, , "[ORDERID] =
Forms![OrderForm].[ORDERID]"

On access 2003 only the orderid selected on the form shown on the
report. on access 2007, all the records shows on the report. it ignore
the where condition...
 
D

Duane Hookom

Add a text box to the report header with a control source of:
=[Filter]
What does it display?


--
Duane Hookom
MS Access MVP

Same problem... anyone?

Allen said:
Concatenate the value from the from into the WhereCondition string:
DoCmd.OpenReport stDocName, acViewPreview, , _
"[ORDERID] = " & Forms![OrderForm].[ORDERID]

There's a couple of other things that can go wrong here, such as if the
record in the form is not saved, or if the form is at a new record. See:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DoCmd.OpenReport stDocName, acPreview, , "[ORDERID] =
Forms![OrderForm].[ORDERID]"

On access 2003 only the orderid selected on the form shown on the
report. on access 2007, all the records shows on the report. it ignore
the where condition...
 
G

Gina Whipp

I use this in Access 2003... (I changed the field names to match yours.)
DoCmd.OpenReport stDocName, acPreview, , "[OrderID]=" & OrderID

I do not reference the form.

HTH,
Gina Whipp

Same problem... anyone?

Allen said:
Concatenate the value from the from into the WhereCondition string:
DoCmd.OpenReport stDocName, acViewPreview, , _
"[ORDERID] = " & Forms![OrderForm].[ORDERID]

There's a couple of other things that can go wrong here, such as if the
record in the form is not saved, or if the form is at a new record. See:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DoCmd.OpenReport stDocName, acPreview, , "[ORDERID] =
Forms![OrderForm].[ORDERID]"

On access 2003 only the orderid selected on the form shown on the
report. on access 2007, all the records shows on the report. it ignore
the where condition...
 

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

Top