Not sure how to look this up, but I am trying to streamline a lookup I have made on a large amount of data.
The data has a date field that is stored in the usual way (dd/mm/yyyy). In a query, I would like to is prompt the user to put in a year, and the query would return items with the year between Jan 1 [year] and Dec 31 [year].
is it possible to do this? can you partially input a date criteria and sub in the date with a prompt?
I've tried a few things but I have not done something like this before. He is what I have tried to just get 1 month to work, but no success:
= 1/31/[YEAR]
= #1/31/[YEAR]#
= "1/31/"&[YEAR]
Also, would it take 1 input to be used 2 times if I used the same name in the []s?
(such as =between [YEAR] and [YEAR])
Last edited by romperstomper; 07-08-2011 at 05:39 PM. Reason: Mark solved
Hi,
In your query, create a calculated field like:
change the "yourdatefield" to the name of your date field.dateyear: YEAR([yourdatefield])
then set the criteria for that field as a parameter like:
Cheers,[Enter the four digit year]
“To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln
I will give that a try, but I found the solution. It goes back to math class, and understanding that you can change both sides of the equation (either side of the equal sign).
What I did was to go into the button that calls up the query and set the "Where" claus to :
Year(<datefield from the query>) = [Check Which Year]
This way it sees to be looking at the year part only of that field in the query and only shows those that match the year entered.
But learning different ways to do things always inproves my outlook on all coding, so thanks for the reply. I will try that out.
Hello
Another way is to use this as your criterion for your date_field:
DatePart("yyyy",[date_field_name])=[Please input year]
David
Access and Excel Developer | UK
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks