G
gg
Hi group,
I have a form with two date boxes-txtFrom and txtTo. When
a user leaves them blank the report displayes all recirds,
when a user enters only starting date (txtFrom) all
records afer the date are displayed, when a user enters
only ending date(txtTo) only the records prior to this
date are displayed.
Problem: When a user enters starting date and ending date
(between txtFrom and txtTo) my form again displayes all
records. Please help me fix this issue:
Private Sub cmdRun_Click()
Dim strWhere As String
If IsNull(Me!txtFrom) = False Then
strWhere = "DATAFIELD >= #" & Format(Me!
txtFrom, "mm/dd/yyyy") & "#"
End If
If IsNull(Me!txtTo) = False Then
If strWhere <> "" Then
strWhere = strWhere & " and "
End If
strWhere = "DATAFIELD <= #" & Format(Me!
txtTo, "mm/dd/yyyy") & "#"
End If
DoCmd.OpenReport "rptComments", acViewPreview, , strWhere
End Sub
I have a form with two date boxes-txtFrom and txtTo. When
a user leaves them blank the report displayes all recirds,
when a user enters only starting date (txtFrom) all
records afer the date are displayed, when a user enters
only ending date(txtTo) only the records prior to this
date are displayed.
Problem: When a user enters starting date and ending date
(between txtFrom and txtTo) my form again displayes all
records. Please help me fix this issue:
Private Sub cmdRun_Click()
Dim strWhere As String
If IsNull(Me!txtFrom) = False Then
strWhere = "DATAFIELD >= #" & Format(Me!
txtFrom, "mm/dd/yyyy") & "#"
End If
If IsNull(Me!txtTo) = False Then
If strWhere <> "" Then
strWhere = strWhere & " and "
End If
strWhere = "DATAFIELD <= #" & Format(Me!
txtTo, "mm/dd/yyyy") & "#"
End If
DoCmd.OpenReport "rptComments", acViewPreview, , strWhere
End Sub