View Full Version : How to choose only one month?


maquino
03-08-2002, 10:44 AM
I believe this is a pretty simple question. I want to be able to choose a specific month to be displayed on my query(wich contains the field "date") when I open it. I only want to display the records on that specific month, and I want access to ask me wich month I want to display every time I run the query.
Someone help me please!

brucesilvers
03-08-2002, 10:54 AM
Not too difficult to do this: Add the following field to the query: Month([Date]) where [Date] is your date field. Then, in the criteria line of that field add the following parameter: [Enter Month]. What this will do is prompt the user with "Enter Month" when they run the query, and will only display records from that month. Note: the month value is a 1 or 2 digit number (1=January, 12=December, etc.) so that you might want to include that in your parameter (eg, [Enter 1- or 2-digit Month (eg, 1=January, 2=December, etc.)]. Whatever you type within the parameter brackets will be the text displayed when the user is prompted.

[This message has been edited by brucesilvers (edited 03-08-2002).]

KKilfoil
03-08-2002, 10:55 AM
First of all, I would avoid 'date' as a field name as it is also a function name. Lets assume you are using [TheDate]

Do you want to the user to input a value from 1 to 12?

Are you looking for data only in the current year, or all years for that month?


Assuming the user in going to enter a number from 1 to 12 and you want ALL records for that month, regardless of year:


Under TheDate criteria in the design grid, try:
DatePart("m",[TheDate]) = [Enter month number]

maquino
03-08-2002, 11:09 AM
Yeah, you're right, I forgot to teel you that I'd also want to specify the year, not just the month. How can I do that?

David R
03-08-2002, 11:33 AM
Make a separate field with the same structure, except use Year() as your function and, obviously, the word in your parameter.

maquino
03-08-2002, 01:16 PM
Thanks a lot guys, it works perfectly!
Cheers