ComboBox Filter

R

Rohit Thomas

Hello All,

I have two combo boxes on a form "CmbStartDate"
and "CmbEndDate". I would like to use the result (date
range) from these controls as a filter for a report. I am
trying to use the following code below but there's seems
to be something wrong with my syntax. Can anyone point out
the mistake and correct it...I been working on this for
hours with disappointing results.

Thanks in advance,
Rohit Thomas

stLinkCriteria = stLinkCriteria & _
" [FileDate] = Between #" & _
CDate(Me.CmbStartDate) & "# And #" & _
CDate(Me.CmbEndDate) & "#"

DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
 
T

tina

take the = sign out of the expression.
" [FileDate] Between #" & _
CDate(Me.CmbStartDate) & "# And #" & _
CDate(Me.CmbEndDate) & "#"

if that doesn't work, try
" [FileDate] >= #" & _
CDate(Me.CmbStartDate) & "# And [FileDate] <= #" & _
CDate(Me.CmbEndDate) & "#"

also, if CmbStartDate and CmbEndDate are in a standard date format (such as
4/29/04), i don't think you'll need the CDate() function.

hth


Rohit Thomas said:
Hello All,

I have two combo boxes on a form "CmbStartDate"
and "CmbEndDate". I would like to use the result (date
range) from these controls as a filter for a report. I am
trying to use the following code below but there's seems
to be something wrong with my syntax. Can anyone point out
the mistake and correct it...I been working on this for
hours with disappointing results.

Thanks in advance,
Rohit Thomas

stLinkCriteria = stLinkCriteria & _
" [FileDate] = Between #" & _
CDate(Me.CmbStartDate) & "# And #" & _
CDate(Me.CmbEndDate) & "#"

DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
 
R

Rohit Thomas

Thanks Tina for you help....that did the trick.

Rohit
-----Original Message-----
take the = sign out of the expression.
" [FileDate] Between #" & _
CDate(Me.CmbStartDate) & "# And #" & _
CDate(Me.CmbEndDate) & "#"

if that doesn't work, try
" [FileDate] >= #" & _
CDate(Me.CmbStartDate) & "# And [FileDate] <= #" & _
CDate(Me.CmbEndDate) & "#"

also, if CmbStartDate and CmbEndDate are in a standard date format (such as
4/29/04), i don't think you'll need the CDate() function.

hth


Hello All,

I have two combo boxes on a form "CmbStartDate"
and "CmbEndDate". I would like to use the result (date
range) from these controls as a filter for a report. I am
trying to use the following code below but there's seems
to be something wrong with my syntax. Can anyone point out
the mistake and correct it...I been working on this for
hours with disappointing results.

Thanks in advance,
Rohit Thomas

stLinkCriteria = stLinkCriteria & _
" [FileDate] = Between #" & _
CDate(Me.CmbStartDate) & "# And #" & _
CDate(Me.CmbEndDate) & "#"

DoCmd.OpenReport stDocName, acViewPreview, ,
stLinkCriteria


.
 

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