By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

How to Where Clause with multiple criteria

P: n/a
I want to open a report using OpenReport and passing it a Where Clause
with multiple criteria.
I know the Where Clause below is way off but it conveys what I need.

Dates are of string type.

DoCmd.OpenReport "rpt_LOG", acViewPreview, , WHERE????

strDate1 = "Friday, July 20, 2007"
strDate2 = "Saturday, July 21, 2007"
strDate3 = "Sunday, July 22, 2007"

"[Weekend_Date] = """ & strDate1 & """ and """ & strDate2 & """ and
""" & strDate3 & """"

Confused
Rick

Jul 17 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"2D Rick" <rb*******@compuserve.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
I want to open a report using OpenReport and passing it a Where Clause
with multiple criteria.
I know the Where Clause below is way off but it conveys what I need.

Dates are of string type.

DoCmd.OpenReport "rpt_LOG", acViewPreview, , WHERE????

strDate1 = "Friday, July 20, 2007"
strDate2 = "Saturday, July 21, 2007"
strDate3 = "Sunday, July 22, 2007"

"[Weekend_Date] = """ & strDate1 & """ and """ & strDate2 & """ and
""" & strDate3 & """"

Confused
Rick
[Weekend_Date] can't be equal to all 3 dates at the same time, you may want
to use OR. Assuming [Weekend_Date] is a date type you need to use # around
the date and supply a date value.

"[Weekend_Date]=#" & datevalue(strDate1) & "# OR [WeekendDate]=#" &
datevalue(strDate2) & "# OR [WeekendDate]=#" & datevalue(strDate3) & "#"

or if your criteria is always Friday Saturday and Sunday

"[Weekend_Date] between #" & datevalue(strDate1) & "#" and "#" &
datevalue(strDate3) & "#"

If [Weekend_Date] stores date and time, add 1 date to last date

"[Weekend_Date] between #" & datevalue(strDate1) & "#" and "#" &
dateadd("d",1,datevalue(strDate3)) & "#"
Jul 17 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.