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

Query criteria to be set

Status
Not open for further replies.

Krash878

Programmer
May 8, 2001
172
US
I have a query that returns info based on month and year.
The full query is

ID — Name — Sum Of TotalFee: TotalFee — Month([tblCloseItem].[DateClosed]) — Year([tblCloseItem].[DateClosed])

I have a form that needs to set the criteria to the Month and Year. I setup the form with a TxtBox called RptMnth. I am trying to get the query look at form with the Folowing codes.
Like (Left([forms]![frmMonthEnd]![RptMnth],2))
Like (Mid([forms]![frmMonthEnd]![RptMnth],3,4))

The text box is to have the month and year put in like MMYYYY so June of 2001 would be 062001.

When the criteria is substituted with just a number like in the month I put 6 and in year I put 2001 it returns all the data needed. I need the criteria to be set from the form. Am I doing something wrong or is there an easier way to get the result I need.

Thanks
Kenny
 
The Month() function returns an *integer* that represents
the month portion of the date. That's why the query works when you enter an *integer* in the criteria section. I believe the Left() and Mid() functions return what the query sees as text. If you really want the user to enter the month and date only, you probably need two text boxes, formated as a number. Then, in the query criteria point to those controls

[forms]![frmMonthEnd]![RptMnth]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top