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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Query values to a form

Status
Not open for further replies.

mlocurci

MIS
Oct 17, 2001
210
US
I have a query that sums a column in a table. That works perfectly. What I want to do, is have a form come up that lets me enter a date range, press a button called query and show me the total in a textbook on the form. I know how to do the date range part, how do I return that value to the form?

Thanks!

-Michael
 
Create a query adding all the fields you need.
In the criteria of the date field enter:
Between [Enter First Date] and [Enter Second Date]

Create a form, design it using the fields you want in details,in record source
enter the query name. In view click "form header/footer"
drag a text box to the form footer and
enter:
=sum([your field])
Click the command button in the tools menu go to the page header or in details create
a command button, click form operation, open form.
click the finish button.
In design view on form click properties and then the command button. click event
the onclick should say "event procedure," click the three dots to the right
and it will open the class module.
click under the "DoCmd.Close"
enter:
DoCmd.OpenForm "Yourformname"
Close the window and open the form.
A "enter Parameter value box will open asking for the first date, enter the date,click OK.
A second "enter Parameter value" box will open asking for the second date, enter the date, click OK.
Your form should open displaying in the details section all of the entries between the first
and second date, if not go to properties and under view select "continuous."
That should do it. If you want another date selection click the command button on the form. It it will close and then reopen the Parameter value boxes for the dates.
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top