My report generates base on 2 date inputs(from textboxes) namely, ProcStartDate & ProcEndDate & a combobox(cmbRptSupplier) to select the supplier:
When I leave my cmbRptSupplier blank (so that I can leave supplier out of my criteria), & fill in 1/2/2013 for ProcStartDate, 14/3/2013 for ProcEndDate, I get ALL the invoices displayed in return for my report. Even with those before 1/2/2013.
I cannot figure out how is this so
Code:
Private Sub btnReport_Click()
Dim strDocName, strWHERECondition As String
strWHERECondition = ""
If Me.cmbRptSupplier = "" Or IsNull(Me.cmbRptSupplier) = True Then
strDocName = "rpt_Invoice_Details"
strWHERECondition = "Date_Received >= #" & ProcStartDate & "# AND Date_Received <= #" & ProcEndDate & "#"
Else
strDocName = "rpt_Invoice_Details"
strWHERECondition = "Date_Received >= #" & ProcStartDate & "# AND Date_Received <= #" & ProcEndDate & "#" _
& " AND Supplier_ID = " & Me.cmbRptSupplier
End If
DoCmd.OpenReport strDocName, acPreview, , strWHERECondition
End Sub
When I leave my cmbRptSupplier blank (so that I can leave supplier out of my criteria), & fill in 1/2/2013 for ProcStartDate, 14/3/2013 for ProcEndDate, I get ALL the invoices displayed in return for my report. Even with those before 1/2/2013.
I cannot figure out how is this so