PC Review


Reply
Thread Tools Rate Thread

strWhere = filter 'between' syntax?

 
 
Maarkr
Guest
Posts: n/a
 
      11th Dec 2007
Trying to do a form filter query to get the query to view records between the
date entered and 15 days later...

strWhere = "shDate= '" & Me.Combo1 & "'"

gives me a simple date filter, but I've struck out trying the parens and the
'between x AND y ' expression

?? plain language = between combo1date and combo1date + 15

thx
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      11th Dec 2007
"Maarkr" <(E-Mail Removed)> wrote in message
news:7EFAB8E2-42EA-4B41-88CE-(E-Mail Removed)...
> Trying to do a form filter query to get the query to view records between
> the
> date entered and 15 days later...
>
> strWhere = "shDate= '" & Me.Combo1 & "'"
>
> gives me a simple date filter, but I've struck out trying the parens and
> the
> 'between x AND y ' expression
>
> ?? plain language = between combo1date and combo1date + 15



Is shDate a date/time field? If it is, you really should be using the date
delimiter # instead of the text delimiter ' to surround your date literals.
You also should make sure your date literals are formatted into either US
date format (MM/DD/YYYY) or an unambiguous international standard format.
Try this:

strWhere = _
"shDate Between " & Format(Me.Combo1, "\#mm/dd/yyyy\#") & _
" AND (" & Format(Me.Combo1, "\#mm/dd/yyyy\#") & " + 15)"

That version lets the query processor do the addition. An alternative would
be to add the 15 days yourself:

strWhere = _
"shDate Between " & Format(Me.Combo1, "\#mm/dd/yyyy\#") & _
" AND " & Format(CDate(Me.Combo1) + 15, "\#mm/dd/yyyy\#")

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
 
Maarkr
Guest
Posts: n/a
 
      13th Dec 2007
thanks...

"Dirk Goldgar" wrote:
> Is shDate a date/time field? YES


> Try this:
>
> strWhere = _
> "shDate Between " & Format(Me.Combo1, "\#mm/dd/yyyy\#") & _
> " AND (" & Format(Me.Combo1, "\#mm/dd/yyyy\#") & " + 15)"


The second version didn't work. I still have an issue where it computes
correctly sometimes, then burps and will show records starting on the 26th of
the month when I've typed in another date, like the 1st. Debug shows
strWhere has the proper dates, like the 1st thru 15th, but why the form shows
the 26th I don't know... I'll need to look at the rest of the form to see
what's going on.
 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      13th Dec 2007
"Maarkr" <(E-Mail Removed)> wrote in message
news:C913CD40-2C24-4D0B-9109-(E-Mail Removed)...
> thanks...
>
> "Dirk Goldgar" wrote:
>> Is shDate a date/time field? YES

>
>> Try this:
>>
>> strWhere = _
>> "shDate Between " & Format(Me.Combo1, "\#mm/dd/yyyy\#") & _
>> " AND (" & Format(Me.Combo1, "\#mm/dd/yyyy\#") & " + 15)"

>
> The second version didn't work.


I may have made a mistake. That was untested air code.

> I still have an issue where it computes
> correctly sometimes, then burps and will show records starting on the 26th
> of
> the month when I've typed in another date, like the 1st. Debug shows
> strWhere has the proper dates, like the 1st thru 15th, but why the form
> shows
> the 26th I don't know... I'll need to look at the rest of the form to see
> what's going on.


That's odd. I'd need to see the specific where clause and exactly what's
being returned, to figure it out.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using strwhere and Like to filter form Ceebaby via AccessMonster.com Microsoft Access Form Coding 8 18th Mar 2008 01:55 PM
Re: troubl using a null field in strwhere Dirk Goldgar Microsoft Access VBA Modules 0 31st Aug 2005 07:05 PM
StrWhere? David Whitaker Microsoft Access Form Coding 1 6th Dec 2004 05:47 PM
Deleting strWhere Selection Sandy Microsoft Access Form Coding 3 14th Sep 2004 12:14 PM
Pass more than 1 value in strWhere Jorge Microsoft Access Reports 5 13th Mar 2004 05:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 AM.