Using InputBox data across multiple queries

  • Thread starter Thread starter GVR_Mike
  • Start date Start date
G

GVR_Mike

I have about 4 different queries in a series of queries that all need
the same date range that is entered by the user at runtime. I can get
the start date and end date using 2 InputBoxes in the VBA but I didn't
want to have to manually write all the query SQL in the VBA and use
DoCmd.RunSQL, the SQL is very long and cumbersome. I'd rather have it
neatly packaged in a query and then DoCmd.OpenQuery. Is there a way to
do this using the data from the InputBoxes? If I just run the queries
back to back it will have to prompt the user for the dates 4 different
times which is very annoying.

thanks.
 
Create a form that you key the dates into.

Have the queries refer to the date fields on the form:
Forms!NameOfForm!NameOfTextbox
 
InputBoxes don't "store" the data for multiple uses outside of the code.
Build a form that has textboxes on it for the user to put the desired
values, and then have the query read the values from that form.

See this article at Allen Browne's site (second method) for an explanation
of how this is done:
http://www.allenbrowne.com/casu-08.html
 
Back
Top