Running a Query that Allows you to enter the dates that you want

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

Guest

I am trying to design a query that you need to input dates to retrieve that
data. Currently I know that if you go into the query itself and make the
criteria for the date "Between 07/20/2006 and 07/22/2006" it will pull the
data from those dates and in between. What I need to know is if I base a
report off of this query, how can give the user the opportunity to put in the
dates with out having to open the query itself? Any help would be greatly
appreciated.
 
Put Between [StartDate] And [EndDate]. The user will then be prompted
for both dates.

Hope that helps!
 
I would never make my users enter values at parameter prompts. Consider
creating a form with a couple controls for entering the dates. Then set your
criteria to something like:
Between Forms!frmDates!txtStart and Forms!frmDates!txtEnd

The form must be open prior to running the query.
 
If you want to be really posh, you can put the references into unbound text
boxes in a switchboard form as I have done so someone can enter the dates and
click on a button.

KRDitch said:
That worked great - Thank you :)

Jeff L said:
Put Between [StartDate] And [EndDate]. The user will then be prompted
for both dates.

Hope that helps!
 
Would this also work if you want to choose an option from a combo box? What
I am trying to do is run a report but I want to have the user choose which
contact to run the report on. Does this make sense?

scubadiver said:
If you want to be really posh, you can put the references into unbound text
boxes in a switchboard form as I have done so someone can enter the dates and
click on a button.

KRDitch said:
That worked great - Thank you :)

Jeff L said:
Put Between [StartDate] And [EndDate]. The user will then be prompted
for both dates.

Hope that helps!
 
Would this also work if you want to choose an option from a combo box? What
I am trying to do is run a report but I want to have the user choose which
contact to run the report on. Does this make sense?

Sure. Use a criterion

=[Forms]![frmSwitchboard]![cboMyCombo]

using the name of your form and combo box control.

John W. Vinson[MVP]
 
I put the following:

=[RerouteForm]![frmSwitchboard]![RerouteContacts]

in the query that is associated with the report - I'm not getting a box that
is allowing them to choose which contact to run the report on - I'm guessing
that I am putting this in the wrong spot - I'm sort of a new user with Access
so not quite sure where to put this information


John Vinson said:
Would this also work if you want to choose an option from a combo box? What
I am trying to do is run a report but I want to have the user choose which
contact to run the report on. Does this make sense?

Sure. Use a criterion

=[Forms]![frmSwitchboard]![cboMyCombo]

using the name of your form and combo box control.

John W. Vinson[MVP]
 
I put the following:

=[RerouteForm]![frmSwitchboard]![RerouteContacts]

I did not suggest this, and it will not work.

The syntax is

[Forms] - look in the Forms collection to find all open forms
[NameOfSomeForm] - the name of the form on which to look
[NameOfSomeControl] - the name of a control on that form in which to
find the criterion
in the query that is associated with the report - I'm not getting a box that
is allowing them to choose which contact to run the report on - I'm guessing
that I am putting this in the wrong spot - I'm sort of a new user with Access
so not quite sure where to put this information

If you want a pop-up prompt just use

[Enter search term:]

without any form names or ! characters. If, instead, you want to allow
the user to choose an item from a combo box, or type into a textbox on
some form (frmSwitchboard, RerouteForm, or some other form), use the
syntax above, and put a button on that form to open another Form or
Report on which to display the data.

John W. Vinson[MVP]
 
Back
Top