Full Version: Form Filter For A Report From A Qry
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
Macano2
I have been trying few ways but i cant seem to return anything after the qry.

I have a report based from a qry, i have a form to filter that qry for specified fields.

Basically I want to print a report from "THIS DATE" to "THAT DATE" and "THIS PERSON"

my form has the two date boxes one for "this date" and one for "that date" and a cbobox for the "this person" and OK button and a CANCEL button.
i have been entering some code in the criteria for the above fields but after i enter the fields and hit OK it returns with a blank report.

Im i forgetting something or is there in easy way for access 2010 to do this. thanks.
Kamulegeya
Hello

How are u filtering the query? Is the query criteria based on those controls on the form?

Or you have a continuous form bound to the query and you have filters on the form to display required records?

Ronald
Macano2
Yes its based on the controls from the form
Kamulegeya
and the report's record source is that particular query?

Why dont you add a button on that form to open the report after the different criteria is entered ?


Ronald
Macano2
yes the report record source is from the qry.

isnt the OK button on my form to run the qry and show the report, because after i enter the desired dates and person i can see the report but no records show up.

is the button you describe i different way and/or does it have different code
Kamulegeya
What is the code for the OK button?

Can you post it ? or is a macro? If it is a macro convert it to VB code and post it

Ronald

Macano2
well i know its code its not a macro.

but i dont have the project infront of me its in my pc at home and im at work will have to reply to you on this tomorrow.

Do you have any suggestions what the code should be for that button or the other button you suggested?
Kamulegeya
I would expect a code to open the report like

CODE
DoCmd.OpenReport "rptName", acViewPreview


and make sure that the query criteria for the different fields refers correctly to the controls on the form

Where i am it is morning .....8.10am local time..... time zone GMT+3


Ronald


Macano2
thanks Ronald.

on the criteria for the qry i have entered for example, if i remember correctly

[Forms]![Pickme]![Date1]

[Forms]![Pickme]![Date2]

[Forms]![Pickme]![cboname]

for the three desired fields on the qry

I know that im probably missing some very small detail.....thats why i decided to get in touch with some pro's
Kamulegeya
I believe that is ok

Ronald
Macano2
Thanks Ronald,

is there an easier way to filter a report like im trying to filter it?

I just want to three fields to filter, between date 1 and date2 and persons name.

is there another way?


Fernando.
Kamulegeya
QUOTE (Macano2 @ May 12 2012, 08:49 AM) *
Thanks Ronald,

is there an easier way to filter a report like im trying to filter it?

I just want to three fields to filter, between date 1 and date2 and persons name.

is there another way?


Fernando.



Yes but i dont think it is easier than the one you are using...

Opening the report with the where clause . Constructing the where clause here could be tricky....it has 2 parts...

U can try( i dont know the your field names ...just guessing here) air code...
CODE
Dim strWhere As String
strWhere = "[YourDate] Between #" & Format(Me.Date1, "mm/dd/yyyy") & "# and #" & Format(Me.Date2, "mm/dd/yyyy") & "#" & " And [NameField] = '" & Me.cboname & " '"

DoCmd.OpenReport "rptName", acViewPreview, , strWhere


In this case i am assuming that the button to trigger the code is on the form you mentioned and the query does not need to have the criteria referring to controls on the form you mentioned.

I have assumed that name field is text/string
Ronald
Macano2
Correct Ronald i will give this a try, i will get back with you with my results.

Thanks again
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.