I am using access 2007 and I am trying to open a report with a range of dates that the user inputs in two textboxes. I am using the code below, however when I run it, it will open the rerport, but with all dates; and I want it to open with the range of dates on the textboxes.
Thanks in advance
[Code=vb]
Private Sub cmdPrintReport_ Click()
Dim pstCriteria As String
If IsDate([txtFirstDate]) And IsDate([txtEndDate]) Then
pstrCriteria = "[DateReceived]" >= "# " & [txtFirstDate] & "# and [DateReceived]<=#" & [txtEndDate] & "#"
DoCmd.OpenRepor t "rptDateReceive d", acViewPreview, , pstrCriteria
Else
MsgBox "You must enter two dates"
End If
End Sub
[/Code]
Thanks in advance
[Code=vb]
Private Sub cmdPrintReport_ Click()
Dim pstCriteria As String
If IsDate([txtFirstDate]) And IsDate([txtEndDate]) Then
pstrCriteria = "[DateReceived]" >= "# " & [txtFirstDate] & "# and [DateReceived]<=#" & [txtEndDate] & "#"
DoCmd.OpenRepor t "rptDateReceive d", acViewPreview, , pstrCriteria
Else
MsgBox "You must enter two dates"
End If
End Sub
[/Code]
Comment