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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date query for a month 2

Status
Not open for further replies.

vertices

IS-IT--Management
Oct 19, 2002
12
0
0
US
I have dug deep into the forums but unfortunately can not find a previous post that pertains to this question.

I have a date field in my Expenses table. It is in the format mm/dd/yyyy. I need to search this table for all records in any given month and year.

I have a form with 3 combo boxes. The first one selects the employees name, the second selects the numerical month (1-12), and the last selects the year.

I wish to be able to select the criteria on the form and then open the report based in this criteria.

However I can't seem to be able to find the proper syntax to tell the query to look at Combo box 2 for the month and combo box 3 for the year. Is this even possible?

Any help would be greatly appreciated.
 
I have tried:

Between #[forms]![frmViewMoExpense]![Month]/1/[forms]![frmViewMoExpense]![Year]# And #[forms]![frmViewMoExpense]![Month]/32/[forms]![frmViewMoExpense]![Year]#

and of course this gives me an incorrect date error. This was theonly thing I could think of.
 
OKay.....here's what you do.....

create two additional fields in your query...one for month and one for year

the month field should be:

DatePart("m", [nameofdatefield])

the year field should be:

DatePart("yyyy", [nameofdatefield])

Set the visible propertyy of each to no (unchecked)

Set the criteria of the month field to:

=Forms![nameofform]![nameoffieldwithmonth]

Set the year criteria to:

=Forms![nameofform]!{nameoffieldwithyear]

That should set your query to include only the month and year of the comboboxes you have given the user to choose with.... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top