Form to change query criteria

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

Guest

I know that some other postings have the answer I need, but I'm not
experienced enough to pick up what I am to do exactly.

I have a query that includes a "City" field. I have been manually changing
the City criteria to get the desired results. I know I can make a form with
an input field that the user can put in the desired city and then use a
button with some sort of On Click command that would change the query City
criteria to the entered city.

I know how to build the form and how to insert a Command Button. I also
know how to get in to edit the code for the command button. I just don't
know what code to put in. Can anyone help?

Also, is there a good, easy to understand reference book to be able to learn
how to program macros and VBA?

Thanks!

Kass
 
I know that some other postings have the answer I need, but I'm not
experienced enough to pick up what I am to do exactly.

I have a query that includes a "City" field. I have been manually changing
the City criteria to get the desired results. I know I can make a form with
an input field that the user can put in the desired city and then use a
button with some sort of On Click command that would change the query City
criteria to the entered city.

I know how to build the form and how to insert a Command Button. I also
know how to get in to edit the code for the command button. I just don't
know what code to put in. Can anyone help?

Also, is there a good, easy to understand reference book to be able to learn
how to program macros and VBA?

Thanks!

Kass

I'd make the link in a Query, not in code.

Let's say your form is named frmCrit, and you have a Combo Box cboCity
giving the user the choice of cities that are valid for your
application (or perhaps a textbox txtCity, if you trust them to spell
the city right and they don't mind typing it in).

As a criterion on your Query use

=[Forms]![frmCrit]![cboCity]

The button code would then open a Form (for onscreen display) or
Report (for printing) based on the query.

John W. Vinson[MVP]
 
Back
Top