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

Help with Between in SQL string

Status
Not open for further replies.

deadhead7

Programmer
Apr 18, 2003
57
US
Need help with this code, I need to do a Between/And for the FROM_DATE and this code has something wrong with it and can not figure it out, Please help

stlinkcriteria = "HICN = '" & Me![HICN] & "' and UPIN = '" & Me![UPIN] & "'" & _
Between "[FROM_DATE]=" & "#" & Me![FROM_DATE] & "#" & _
and "[FROM_DATE]=" & "#" & Me![FROM_DATE] & "#
 
The syntax for Between is:

ColumnName Between LowValue and HighValue

So try:
Code:
stlinkcriteria = "HICN = '" & Me![HICN] & "' and UPIN = '" & _
Me![UPIN] & "' AND [FROM_DATE] " & _
"Between #" & Me![FROM_DATE] & _
"# And #" & Me![TO_DATE] & "#"

This assumes you have a control called [TO_DATE] on your form. If the end date is calculated use the DateAdd function to produce the end date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top