Criteria that will find date by month

SlinkRN

Well-known Member
Joined
Oct 29, 2002
Messages
724
Hi again!
Is there a way to use wild cards to find all the dates from a certain month in a query. I tried [Please enter number of month]/**/**** but that didn't work. I'd like the user to be able to enter a month and then see all the records that are included in that month. The year doesn't need to be entered although it should show in the resulting records.
I was using Between [Please enter beginning date] AND [Please enter ending date], but the user will always want to see a month worth of records, so I want to make it easier to enter.
Can anyone help?
Thanks, Slink
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
One way to do this would be to set up an option group on a form with each month listed and a little radio button next to each. Naturally, January would return a value of "1" and so forth. Then you would have a button on the form whose OnClick event would open a very simple macro (or code, if you like) that would run the query. The criteria for the field in question on the query should be:

Month([name of your field])=[forms]![name of the form with the option group]![name of the option group]

Hope that helps.
 
Upvote 0
Thanks. I tried your solution (and maybe I was entering the criteria incorrectly) but it wouldn't work for me. I'm thinking it was because my field is an entire date and not just a month. Anyway, I re-searched the help menu and found this solution:
In the criteria field of the date, I entered:
Like [Enter the month number - for example, 5] & "*"
This brings up all the records from the month entered. If you want to include the year you can use:
Like [Enter the month number - for example, 5] & "*" & [Enter year]
 
Upvote 0
You do have to be careful with your syntax when entering the code I put in, and you have to use the real names of objects, not just the captions. The purpose of the stuff I put was so the information could be chosen from a dialog box, not typed directly into the query. To use my solution your way, the syntax for the criteria of the field in question would be:

Month([keep the name of your field here])=...Type in the number for the month in question...

And don't use the ellipses. To use your solution my way, you would still set up an option group or a combo box that returned number values for the month, and then opened the query, and the criteria would be:

Like [forms]![name of the dialog box form]![name of the option group]&"*"
 
Upvote 0

Forum statistics

Threads
1,221,586
Messages
6,160,646
Members
451,661
Latest member
hamdan17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top