Button function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a couple of questions I hope someone can help me with

1. When I push a button in a form, I want a value in a text-box to be "saved" and brought along as a criteria in a quer
2. Run the Query, which is a make-table query, without any of the question
3. Open a repor

What is the easiest way to do this

Thanks in advance
 
I have a couple of questions I hope someone can help me with.

1. When I push a button in a form, I want a value in a text-box to
be "saved" and brought along as a criteria in a query 2. Run the
Query, which is a make-table query, without any of the questions 3.
Open a report

What is the easiest way to do this?

Thanks in advance


Create an unbound form.

Let's assume you wish to limit records to between 2 dates.
Add a text control for each criteria entry.
Name one control 'FromDate'.
Name the second control 'ToDate'.
Set their Format property to a Date format.

Add a Command Button to the form.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

In the Query, as criteria for the Date field ,write:

Between forms!ParamForm!FromDate And forms!ParamForm!ToDate

Next, create a Report that has the Query as it's Record Source.
Code the report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the report's Close event:
DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report.
The form will open and wait for the selection of the To and From
Dates.
Click the command button on the form and then report will run.
When the report closes, it will close the form.
You will NOT see the query and will not be prompted for the
parameters.
 
Back
Top