Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Month/Year

Status
Not open for further replies.

qshaz

Technical User
Feb 1, 2002
17
0
0
AE
Hello
I am sure there is some easy way to do this...but I have a date field in my table and my users need to search for records with the crietria as year and then month. Is there any way to do this, or must I have two fields? And how do I then allow them to search first by year and then by month to see the records they want?

Thanks
Shazia
 
Hi Shazia:

I am not sure what format your date field is in. But take a look at these two functions and see if one of them will suite your purpose:

DatePart() Returns the specified part of a date sucha as day, month, year.

Year() Returns the year of a date value as an integer
Month()Returns the month of a date value as an integer

Look in help for these functions to get the syntax correct.

I hope this helps
Trudye
 
Thanks Trudye!

As a matter of fact, I did end up using Year() and Month() and it worked great...I have another question...probably sounds stupid...but is there anyway that if a user enters a month in the field it input it in the table as the current date? This is because they will only be entering monthwise data and are getting irritated at having to enter a date everytime.

Thanks again!
 
I find it more attractive to add the Calendar control to the field so when the user clicks in the field the calendar suddenly appears and they can select the date by clicking instead of typing. Once they click the date it fills the field with the date and then the calendar disappears.
I am still not entirely sure of the code to ensure a date earlier than the current is entered?
 
Yes, I would like to know the code for that as that would prevent them entering data for a month in the future, in which case my calaculations (which are based on every month and the calculation for the month prior to it) would be messed up.

But I still would like to know that if they enter 01 or jan in a date field, it takes it as the last date of the month they entered in the table but since the field is formatted as mmmm it still shows them January!

Thanks!
Shazia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top