pass parameter to report

avniaren

New member
Local time
Today, 12:07
Joined
Aug 26, 2006
Messages
3
i want to
use a query "above45" to show the report "report overdue".The query takes "state" from form frmoverdue "cbostate" combo box.
i am using docmd.openreport "report overdue",acviewpreview","above45","[state]=Forms![frmoverdue].[cbotext].[seltext]"
but I am not getting the data.I am getiing two rows and one column.contining
cbotext
AZ
if AZ is selected from the form.
 
I could be wrong, as I often am, but I believe you have an unnecessary quotation mark in your statement. It's right after acPreview, before the comma.

Statement should be:

DoCmd.OpenReport "Report Overdue", acViewPreview, "above45", "[state]=Forms![frmoverdue].[cbotext].[seltext]"

It's always something, isn't it?
 
It is still not working.
 
I know how frustrating this stuff can get. It's driven me crazy, and this is how I ended up!

I have found that it's important to have a way to trace a problem, then I can usually find where I've gone wrong.

One thing you can do which will help you see where the problem is:

1. Change the query "above45" so that it looks to the form 'frmoverdue' for it's criteria. You would do this in Design View of above45. In the row below the field "State" labelled critera, put your criteria, "=Forms![frmoverdue].[cbotext].[seltext]"

Now open the form, set the cbotext box to a criteria you want to test, and open the query above45 to see if it pulls up the data you desire. The query is looking at the form for it's filter criteria, and will work or it won't work. If this works, you're good to go to the next easy step.

If not, you've found the source of your problems... most likely that the criteria is not referenced correctly. Check the spelling of form name, control name, etc. (I'm a little confused about the last suffix 'seltext' in your criteria string, as it seems to be one too many.

2. Once you get the query to pull up the correct data, you can simply base your form on that query. You would then open the form but with a simpler: docmd.openreport "report overdue",acviewpreview .

Hope this jostles you into success!
 
the query is puling data but when we docmd.openreport "rptoverdue".acviewpreview then no data is accessed by the report
eg
If we insert state as AZ and run the query then query pulls records,say 5,the report also pulls 5 records but when called through the form the report does not show data.
 
"If we insert state as AZ and run the query then query pulls records"

How are you doing that?
 
Is the Record Source for the report "above45" ?

When you open the report with the docmd.etc. is the form "frmoverdue" open?
 

Users who are viewing this thread

Back
Top Bottom