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

  • Thread starter Thread starter oranmeir
  • Start date Start date
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?
 
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
 
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...
 
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...
 
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...
 
Back
Top