Filtering a report

Rob.Mills

Registered User.
Local time
Today, 15:36
Joined
Aug 29, 2002
Messages
871
I have setup a command button on a form to print a report based on the records in the continuous form. I've also setup a query to filter the records for the report. The query has two fields with criteria. One I've set in the query the other pulls the criteria from the form with the button. When I open the query in datasheet view it works fine. But when I go to print the report it opens two windows asking for the criteria that I've already established.

Why is this happening???:confused:
 
Does the button print the report?
If so, does the form remain open when the report is printing?
what type of query are you using for the report, a crosstab query or a simple select query?
 
Right now I have the button setup to open the report in preview and the form does stay open.

I'm using a simple select with one field's criteria pulling from a field on the form.
 
What is the code behind the button?
 
Public Function FilterEntering(filter As String)

DoCmd.OpenReport "Print report", acViewPreview, filter

End Function

OnClick property is =FilterEntering("W/Statusqry")
 
I suspect it is due to the filter argument of the openreport method but I have not used the filter argument of the openreport method. Instead I either use a criteria in the where clause of the openreport statement or use a query by form for the report's recordsource.
If you are using a filter, you must make sure that the filter query has all the same fields that are in the report.
I think it would be easier for you to use one of the 2 methods I have described above (unless anyone can give a solution to your exact problem)
 
I'm sure you're right about that. I'm still new to VB and I've tried entering a where clause but have never made one work. Is there any resources you can direct me to to learn about that?
 
Windows help is quite easy to follow or give a little more info and the criteria you are trying to implement and we'll be able to give you an example here.
 
Thanks Fizzio

I was going to post virtually the same question, but was able to solve my problem in 5 minutes thanks to your help. I've been grappling with this problem for almost 2 weeks w/o a solution. I used the method you suggested using a query by form as my record source. Making sure that all my fields were in the query and then using the [Enter Criteria] for the criteria in the field I wanted to choose worked perfectly. I then used a button on the form so I can call up the specific report for the record I want using that criteria. I'm not sure if this makes sense to anyone else, but I just wanted to post to tell others that this method works well.

thanks again

Path
 
There is an answer for nearly every problem here, tucked away in a dark corner somewhere. I have learned most things from here (with a little experimentation)
Look and Ye Shall Find !
 

Users who are viewing this thread

Back
Top Bottom