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!

Select Where variable error

Status
Not open for further replies.

LarryViles

Programmer
Jul 1, 2009
2
US
In Access 2003 I have the following statement as part of a report. I wish to change the literal '8' to a more user friendly variable (like ThisMonth). Every attempt to do so results in an error message.

rst.Open "SELECT [Birthday Query Sub].[1stResident], DatePart('d',[1stBirthday]) AS Birthdate FROM [Birthday Query Sub] WHERE (((DatePart('m', [1stBirthday])) = 8)) ORDER BY DatePart('d',[1stBirthday]);"

Larry


 
dim intMonth as integer
intMonth = datepart("m",Date())

substitute intMonth for 8

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Code:
rst.Open "SELECT [1stResident],Day([1stBirthday]) AS Birthdate FROM [Birthday Query Sub] WHERE Month([1stBirthday])=" & ThisMonth & " ORDER BY 2"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top