Using InputBox data across multiple queries

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.
 
D

Douglas J. Steele

Create a form that you key the dates into.

Have the queries refer to the date fields on the form:
Forms!NameOfForm!NameOfTextbox
 
K

Ken Snell \(MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top