Solved

Creating a parameter query in Access that prompts for dates?

Posted on 2013-11-25
5
213 Views
Last Modified: 2013-12-18
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
Comment
Question by:agwalsh
  • 2
  • 2
5 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39674197
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
 

Author Comment

by:agwalsh
ID: 39675264
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
 
LVL 84
ID: 39675539
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
 
LVL 34

Accepted Solution

by:
PatHartman earned 250 total points
ID: 39675548
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
 

Author Closing Comment

by:agwalsh
ID: 39726967
Had to go a different route but this was helpful :-)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now