Here is some code you can pattern after...
'~~~~~~~~~~~~~
Sub SetReportFilter( _
ByVal pReportName As String, _
ByVal pFilter As String)
' written by Crystal
' Strive4peace2007 at yahoo dot com
' PARAMETERS:
' pReportName is the name of your report
' pFilter is a valid filter string
' USEAGE:
' SetReportFilter "MyReportname","someID=1000"
' SetReportFilter "MyAppointments", _
"City='Denver' AND dt_appt=#9/18/05#"
On Error Goto Proc_Err
'---------- declare variables
Dim rpt As Report
'---------- open design view of report
' --- and set the report object variable
DoCmd.OpenReport pReportName, acViewDesign
Set rpt = Reports(pReportName)
'---------- set report filter and turn it on
rpt.Filter = pFilter
rpt.FilterOn = IIf(Len(pFilter) > 0, True, False)
'---------- change a label caption
rpt.Label_controlname.caption = "New Caption"
'---------- save and close the changed report
DoCmd.Save acReport, pReportName
DoCmd.Close acReport, pReportName
'---------- Release object variable
Set rpt = Nothing
Proc_Exit:
Exit Sub
Proc_Err:
msgbox err.description,, _
"ERROR " & err.number & " SetReportFilter"
'press F8 to step thru code and fix problem
'comment next line after debugged
Stop: Resume
'next line will be the one with the error
resume Proc_Exit:
End Sub
'~~~~~~~~~~~~~~~
Warm Regards,
Crystal
Microsoft Access MVP 2006
*
Have an awesome day
remote programming and training
strive4peace2006 at yahoo.com
*