Following the same example... DateF & DateT are the dates range
In this example the date range is not optional
Code:
Sub Somewhere
Dim DateF As Date
Dim DateT As Date
'
'here set date values from some controls
'
End Sub
Private Sub cmdPrint_Click()
Dim MySF As String
MySF = "{tablex.fieldx}='" & txtBank.Text & "'"
MySF = MySF & " And {tablex.datex} >= Date(" & Format(DateF,"yyyy,mm,dd") & ")"
MySF = MySF & " And {tablex.datex} <= Date(" & Format(DateT,"yyyy,mm,dd") & ")"
Report1.ReportFileName = App.Path & "\Report\abc.rpt"
Report1.WindowShowPrintSetupBtn = True
Report1.WindowState = crptMaximized
Report1.SelectionFormula = MySF
Report1.Action = 1
End Sub
(just change table & field for the real names)