Combo Boxes

hooby1

Registered User.
Local time
Today, 13:40
Joined
May 9, 2004
Messages
48
Im new in using Access 97 and would like some help. Basically I have two combo boxes on a form - one containing Months of the year Jan...Dec that I have typed in manually and the second one containing years 1999....2006 (Also manually typed in). On a table I have got data on food and one of the columns is expiry date(Set as Date/Time data type in 22/06/2004 format) for example. I have got a form with these combo boxes on and Im stuck on the code. What I would like is for me to select from the first combo box (Month) say June and then select from the year combo box (Year) say 2004 and then press a command button that will look at the selected choices which looks at the expiry date column in the table, and process a report with everything expiring in June 2004. Would I go around this by making a hidden text box which temporary holds the selected month and year then processes a query along the lines of Between 01/06/2004 and 30/06/2004 (or between the first day of the selected month and year to the end of the selected month and year)??? Not sure how you go around it as it's set out as dd/mm/yyyy format and I only want the month and year looking at. Im totally stuck and dont know where to begin. Im new to Access and I would like this as it helps me look at my data better. Cheers. Hope someone can help?
 
I would suggest you have a look at the "datepart" function that has the ability to extract the month part and the day part of your dates separately, you can use these then to produced the query you want.
 
DatePart Function

Cheers for the quick reply. I am new to Access is this what I would do? Keep the Months and Years Combo boxes on the form, make a query and select the column with the expiry date and insert this in the query:
Month: DatePart('m',[thecolumnthatholdstheexpirydate]) and then the same in the year column
Year: DatePart('m',[thecolumnthatholdstheexpirydate]). How would I then use this in using the selected Month and Year from the combo boxes and show the expiry dates for this month and year? Bit confused here. Cheers for the quick reply.
 
Last edited:
This should be: Year: DatePart('m',[thecolumnthatholdstheexpirydate])

Like this for the year:
Year: DatePart('yyyy',[thecolumnthatholdstheexpirydate])
 

Users who are viewing this thread

Back
Top Bottom