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

Syntax Headaches

Status
Not open for further replies.

Rjc8513

Technical User
Feb 12, 2001
140
US
Can Between...And be used in a VBA SQL statement? I can't seem to find any reference in the Help files and can't get the syntax correct when trying to write it in VBA.

dbs.CreateQueryDef "qry- EMF ARCHIVE", _
"SELECT * FROM [qry- EMF DATA] " _
"WHERE [YRPP] Between " & BegYRPP & " And " &
EndYRPP & ";"

BegYRPP and EndYRPP are variables.

Thanks.
 
Yep.

If you're having trouble with that particular statement, you should add # signs before and after each of the variables (assuming they're dates).

dbs.CreateQueryDef "qry- EMF ARCHIVE", _
"SELECT * FROM [qry- EMF DATA] " _
"WHERE [YRPP] Between #" & BegYRPP & "# And #" &
EndYRPP & "#;"

They work like single quotes do for text variables.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top