Dat range in reports

T

Tom van Stiphout

On Thu, 22 Jan 2009 05:58:40 -0800 (PST), STiruchi

Study the example. Use the debugger to step through the Filter_Click
event. For date fields, rather than wrapping with Chr(34), you wrap
with #-signs.
So your where clause becomes:
.... where myDateField between #1/1/2009# and #1/31/2009#

-Tom.
Microsoft Access MVP
 
D

Douglas J. Steele

In section 8, where it shows code for the OnClick property of the second
command button, the assuming is that each of the five fields are Text
fields: that's what the Chr(34) function calls are for (they put double
quotes at the front and end of the text that was keyed into the text boxes).

For dates, you need to delimit the values with # characters, and the date
must be in either mm/dd/yyyy format or an unambiguous format such as
yyyy-mm-dd or dd mmm yyyy, regardless of what your Short Date format may be
set to. That means that assuming you can identify the specific control which
is supposed to contain a date, you'd use code like

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Format(CDate(Me("Filter" & intCounter)), "\#yyyy\-mm\-dd\#") &
_
" And "

Incidentally, if your fields are numeric, just leave out the Chr(34)
function calls:

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Me("Filter" & intCounter) & " And "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top