Filter report

  • Thread starter Thread starter Ernst Guckel
  • Start date Start date
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.
 
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
 
Back
Top