formatting a text box control for use in query criteria? (1 Viewer)

SirStevie3

Registered User.
Local time
Today, 12:20
Joined
Jul 29, 2013
Messages
58
I have a totals query that provides an avg for each month. i'd like to be able to use a text box control (named "Date") on a form (named "Report Runner") to show only a certain month and it's avg.

I tried using this as criteria on the "MonthGroupPMC" field:
Code:
Format([Forms]![Report Runner]![Date], "yyyy-mm")

but the results came up blank.

how can i filter the results of this query to show only one month, specified by the [Forms]![Report Runner]![Date] control?
 

Attachments

  • MSACCESS2.JPG
    MSACCESS2.JPG
    13.1 KB · Views: 129
  • MSACCESS1.JPG
    MSACCESS1.JPG
    19.2 KB · Views: 125
  • MSACCESS3.JPG
    MSACCESS3.JPG
    29.1 KB · Views: 127

pr2-eugin

Super Moderator
Local time
Today, 20:20
Joined
Nov 30, 2011
Messages
8,494
Try this WHERE to your SQL.
Code:
WHERE Month(Date_Sent) = Month([Forms]![Report Runner]![Date]);
 

SirStevie3

Registered User.
Local time
Today, 12:20
Joined
Jul 29, 2013
Messages
58
got an error (attached screenshot)

tried making the Format(Date_Sent,"yyyy-mm") match your Month(Date_Sent) but got the same error...

:(
 

Attachments

  • MSACCESSerror.JPG
    MSACCESSerror.JPG
    11.9 KB · Views: 125

Mihail

Registered User.
Local time
Today, 22:20
Joined
Jan 22, 2011
Messages
2,373
Not for sure but I suspect that the "Date" name cause the troubles.
The "Date" is a reserved word. So, Access expect some arguments after this (reserved) word that you use in the SQL string.
Try to change all names in something like StartDate or EndDate etc.
 

SirStevie3

Registered User.
Local time
Today, 12:20
Joined
Jul 29, 2013
Messages
58
tried changing it to Date1 and Text63 but neither worked.

what is a syntax error anyway?
 

SirStevie3

Registered User.
Local time
Today, 12:20
Joined
Jul 29, 2013
Messages
58
guess i had the SQL statements in the wrong order.

I got it!! thank you guys!
 

Users who are viewing this thread

Top Bottom