passing inputbox text to query expression(?)

G

Guest

I have a database with four similar queries that generate four separate
reports. I have a macro to print the four reports but they each require a
date input from the user for an expression in the queries. The input will
always be the same for each query at an given time. How can I get the macro
to prompt the user for the date one time for the separate queries, instead of
having them enter the date once for each query. (Im new to access vba).
 
A

Alex White MCDBA MCSE

Hi,

Create all 4 queries that they are requiring dates for input like below

SELECT TEMP_ASSIGNMENT.ASSIGNMENT_ID WHERE
(((TEMP_ASSIGNMENT.END_DATE)>=[forms]![Menu]![StartDate]) AND
((TEMP_ASSIGNMENT.START_DATE)<=[Forms]![menu]![EndDate]));

in the above example create a form called menu and have two textboxes one
called StartDate and one called EndDate, when the query is run it will take
the values from the form. The form has to be open and with valid values.

Hope it helps
 
S

Steve Schapel

CK,

Instead of using a Parameter Query, place an unbound textbox on a form
which will be open at the time you want to print your reports. The user
can enter the date into this textbox, and then in the criteria of the
queries, in the place of the parameter prompt, you can refer to the
textbox, using syntax such as...
[Forms]![NameOfYourForm]![NameOfTextbox]
 
G

Guest

Thank you both, I think between these two suggestions we've got it licked.


Steve Schapel said:
CK,

Instead of using a Parameter Query, place an unbound textbox on a form
which will be open at the time you want to print your reports. The user
can enter the date into this textbox, and then in the criteria of the
queries, in the place of the parameter prompt, you can refer to the
textbox, using syntax such as...
[Forms]![NameOfYourForm]![NameOfTextbox]

--
Steve Schapel, Microsoft Access MVP

I have a database with four similar queries that generate four separate
reports. I have a macro to print the four reports but they each require a
date input from the user for an expression in the queries. The input will
always be the same for each query at an given time. How can I get the macro
to prompt the user for the date one time for the separate queries, instead of
having them enter the date once for each query. (Im new to access vba).
 

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

Top