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

strfilter by dates

Status
Not open for further replies.

trustsun

Technical User
Feb 4, 2004
73
US
Hi,

Trying to filter a date field, but I'm having trouble. Could someone revise this?

Private Sub cmdMonthstotals_Click()
On Error GoTo MyErr
Dim MyVar As String
strFilter = strFilter & "#CHGDATE#=" & Nz(Me![Combo7], "#CHGDATE#")
DoCmd.OpenReport "myreport", acViewPreview, strFilter
MyExit:
Exit Sub
MyErr:
If Err.Number <> 2501 Then
MsgBox Err.Description
End If
Resume MyExit
End Sub

-thanks
 
strFilter = "txtDate =#" & & Nz(Me![Combo7], CHGDATE) & "#"

Qu'est-ce que c'est "CHGDATE"?
Is it a global variable, a field, a function???
 
well then, what I showed you should work as is?
 
Sorry, but it doesn’t work. Yours comes up with the compile error.
I compared what I have and your example with some modifications and this work but the report want filter now. I get the infamous "error" on my reports. Here's what I use:

strFilter = strFilter = "#[CHGDATE]#=" & Nz(Me![Combo7], "#[CHGDATE#]") & "#
 
why strFilter = strFilter....
is your field called "#[CHGDATE]# or [CHGDATE#]
or is it [#CHGDATE#]

...i put one too many ampersands in my last thread

strFilter = "txtDate =#" & & Nz(Me![Combo7], CHGDATE) & "#"

strFilter = "[#CHGDATE#]=#" & & Nz(Me![Combo7], [#CHGDATE#]) & "#"

 
The field name is just CHGDATE. Neither one of the last examples you gave works. I'm filtering by months like Format$([CHGDATE],"mmmm yyyy",0,0)from the reports when I select a month from the form. But the underline query CHGDATE field is mm/dd/yy.

 
strFilter = "[CHGDATE]=#" & & Nz(Me![Combo7], [CHGDATE]) & "#"

what is the value of combo7?
 
I keep getting (can't find the field '|' referred to in your expression) I bet it something simple?

 
strFilter = "[CHGDATE]=#" & Nz(Me![Combo7], [CHGDATE]) & "#"
ONE AMPERSAND

WHAT IS THE VALUE of Combo7. what format is it in?
 
The value for Combo7 is a date format exp. mm/dd/yy.
 
This works, right?

strFilter = "[CHGDATE]=#" & Nz(Me![Combo7], Date) & "#"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top