Apply a filter

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

Guest

Please help - I am sure the answer to this is soooo easy
but I am going around in circles.

I wish to filter a query based on the name selected by a
dropdown box on a form. e.g I have 650 clients. By
selecting one name from a form I wish to filter the query
so that I can create a letter to that one client.

Can I do this with a macro?
 
Please help - I am sure the answer to this is soooo easy
but I am going around in circles.

I wish to filter a query based on the name selected by a
dropdown box on a form. e.g I have 650 clients. By
selecting one name from a form I wish to filter the query
so that I can create a letter to that one client.

Can I do this with a macro?

Set the query criteria for the ClientID field to:
forms!FormName!ComboName
Make sure the datatype of the combo box's bound column is the same as
the datatype of the query field.

The form must be open when the query is run.
If this is for a report (using this query as it's record source), the
usual way is to open the form from the Report's Open event using:
DoCmd.OpenForm "FormName", , , , , acDialog

Add a command button to the form. Code it's click event:
Me.Visible = False

Close the form in the Report's Close event:
DoCmd.Close acForm, "FormName"

When you wish to run the report, open the report.
It will open the form.
Select the client.
Click on the command button.
The Report will run. When you close the report it will close the form.
 
Back
Top