Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Driving queries with forms

Status
Not open for further replies.

accessNEWB

Technical User
May 20, 2002
10
CA
Perhaps another newb question, but I searched forums and couldn't find anything.

I need to populate a report based on a query. I need to set the criteria on a query based on a value from a form (the year, to be exact). once the queries goes, the Report should contain only entries from the query. I believe that all I need to do is set the control source of the text boxes to the query (correct me if I'm wrong), but to set the criteria - No clue.

Thanks for the help!
 
Create a form with a text box and call it Txt_Year

Have the form open and open your query in design view.

Click in the Criteria for the field that holds the date.

Run the Expression Builder, Magic wand button on the toolbar

In the left pane double click Forms, and then loaded forms (thats why we have the form open) and then double click the text box Txt_Year

The expression should look something like

Forms![Frm_Staff]![Txt_Year]

Click Ok and then change the report to use this query if needed, add a command button using the wizard to preview the report.

That should be it

Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
in the criteria for the queries

=[forms]![myform]![txtElement] will do it. This takes the item in the form and uses that element (txtbox etc) to drive the query. I do this for all my reports. I activate the process off a button to print the report that has the control source as the query.

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanks guys, works like a charm. Now, to get the report to update when the query is run. I have textboxes with
=[qryMonthlyReport]![Amount] and such as the control sources. When I run the query, the Report doesn't update. The query is run from the datbase control, I enter in a date, nice new window pops up showing me the query results, but report - she just doesn't update.

Thanks for you help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top