I am using the following code which works perfectly.
What am unable to get is the date range is not present on the report.
How and what should I add to this code to get the date range mentioned on the report.
example: Between Date: 01-Jan-2015 To Date: 26-Jan-2015
Private Sub cmdOpenReportSingle_Click()
On Error GoTo Err_Handler
Const REPORTNAME = "General Sales Dialog"
Const MESSAGETEXT = "Both a start and end date must be selected."
Dim strCriteria As String
Dim strDateFrom As String, strDateTo As String
' make sure a Dates are selected
If Not IsNull(Me.cboDateFrom) And Not IsNull(Me.cboDateTo) Then
strDateFrom = "#" & Format(Me.cboDateFrom, "yyyy-mm-dd") & "#"
strDateTo = "#" & Format(DateAdd("d", 1, Me.cboDateTo), "yyyy-mm-dd") & "#"
' build string expression to filter report
' to selected date range
strCriteria = "TransactionDate >= " & strDateFrom & " And TransactionDate < " & strDateTo
' open report filtered to selected Dates
DoCmd.OpenReport REPORTNAME, _
View:=acViewPreview, _
WhereCondition:=strCriteria
Else
MsgBox MESSAGETEXT, vbExclamation, "Invalid Date Operation"
End If
Exit_Here:
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_Here
End Sub