Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Creating a parameter query in Access that prompts for dates?

Hi Folks
Just wondering how I would create a parameter query in Access that prompts for a month rather than a specific string? Thanks.
0
agwalsh
Asked:
agwalsh
  • 2
  • 2
2 Solutions
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I'm not a big fan of "prompting" queries. You would be much better served to create a small form where your users enter the values and you pass those along to the Form or Report you're trying to use with that query.

If you must, however, then do something like this in the Criteria row of your query:

[Enter Closing Date:]

And access will show the user the Inputbox with "Enter Closing Date:". Of course, you have no control over the format of what the user enters, so if they put in "spot" then Access will throw a nasty error.

See this MSDN article for more information: http://office.microsoft.com/en-us/access-help/use-parameters-to-ask-for-input-when-running-a-query-HA102809759.aspx
0
 
agwalshAuthor Commented:
hm, I've shown them how to do the form thingy but one of the people I was working with had seen it in a query (date dropdown) and wanted to know how to do it...but will try out your suggestions...thank you :-)
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
FWIW - Users really should not be interacting directly with queries (or tables), simply because there is a great risk of data destruction or modification.
0
 
PatHartmanCommented:
If you use a form, you can use a combo or a text box and if you are not entering a real date, you should validate the data before using it.  Access will validate dates as long as you define the control with a date format.  If you want just a month (I'm not sure why you don't also want year), you should have a validation rule that limits the value to 1-12.

It is also poor practice to open queries for users to interact with so a form or report would be better.  Then you can pass in the "date" with the OpenForm/OpenReport by using the Where argument
0
 
agwalshAuthor Commented:
Had to go a different route but this was helpful :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now