Link to home
Start Free TrialLog in
Avatar of gbnorton
gbnortonFlag for United States of America

asked on

run a query from a command button with criteria

I have a query I would like to run from a command button.  I would like to include the criteria for the date_run field.

In English it would look like this:

Run qryGlassing_Schedule where date_run = #2/16/2011#.

Thanks,
Brooks
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

So say your SQL for qryGlassing_Schedule is:

SELECT Table1.*
FROM Table1
WHERE (((Table1.date_run)=[Enter Run Date:]));

Private Sub btnOpenQry_Click()

DoCmd.OpenQuery "qryGlassing_Schedule ",acViewNormal

End Sub

You will get a prompt to enter the date.  Is this what you mean?

mx
If the Date is somewhere on the form, or is today's date then in the criteria field of the query - right mouse click  - build and point the where you want to get the date field from.

If you want to click the button and have the program prompt for the info then just use the [enter date] in the criteria field of the query
ASKER CERTIFIED SOLUTION
Avatar of GRayL
GRayL
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gbnorton

ASKER

Perfect!
Thanks again.
Thanks, glad to help.