Filter report

E

Ernst Guckel

hello,

I have a report that I want to filter by SOSID. here is some code...


txtMealDate holds a date and if I put

[SOSID] = 1 in the filter field of the report it filters fine but if I open
the report with this code it shows all data (not filtered) but strFilter
contains the right values?? Any ideas??

Public Const STRING_DATE As String = "\#mm/dd/yyyy\#"

stDocName = "rptMeals"
strFilter = "[SOSID] = " & DLookup("[SOSID]", "tblSOS", "[SOSDate] = " &
Format(Me.txtMealDate, STRING_DATE))

DoCmd.OpenReport stDocName, acViewPreview, strFilter

Thanks,
Ernst.
 
A

Allen Browne

You are missing a comma:
DoCmd.OpenReport stDocName, acViewPreview, , strFilter
 
E

Ernst Guckel

Thanks... works great now :)

Ernst.


Allen Browne said:
You are missing a comma:
DoCmd.OpenReport stDocName, acViewPreview, , strFilter

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ernst Guckel said:
I have a report that I want to filter by SOSID. here is some code...

txtMealDate holds a date and if I put

[SOSID] = 1 in the filter field of the report it filters fine but if I
open
the report with this code it shows all data (not filtered) but strFilter
contains the right values?? Any ideas??

Public Const STRING_DATE As String = "\#mm/dd/yyyy\#"

stDocName = "rptMeals"
strFilter = "[SOSID] = " & DLookup("[SOSID]", "tblSOS", "[SOSDate] = " &
Format(Me.txtMealDate, STRING_DATE))

DoCmd.OpenReport stDocName, acViewPreview, strFilter
 
Top