T
Ted
I am pretty much a vb noob and found some code to run an unbound form for a
clients database which I have altered:
I have a search section in the header of the form with a few unbound fields
, UnboundDateOpenedStart , UnboundDateOpenedEnd & UnboundFileNo all across
the top.
what i want to know is how can I create another row of criteria I mean
where exactly and how do i specify the OR condition in the following code,
assuming the 2nd set of unbound fields would be UnboundDateOpenedStart2,
UnboundDateOpenedEnd2 & UnboundFileNo2 :
Thanks for any help ahead of time
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
If Not IsNull(Me.UnboundDateOpenedStart) Then
strWhere = strWhere & "([OpenDate] >= " &
Format(Me.UnboundDateOpenedStart, conJetDate) & ") AND "
End If
If Not IsNull(Me.UnboundDateOpenedEnd) Then
strWhere = strWhere & "([OpenDate] <= " &
Format(Me.UnboundDateOpenedEnd, conJetDate) & ") AND "
End If
If Not IsNull(Me.UnboundFileNo) Then
strWhere = strWhere & "([FileNum] like """ & Me.UnboundFileNo & """)
AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
clients database which I have altered:
I have a search section in the header of the form with a few unbound fields
, UnboundDateOpenedStart , UnboundDateOpenedEnd & UnboundFileNo all across
the top.
what i want to know is how can I create another row of criteria I mean
where exactly and how do i specify the OR condition in the following code,
assuming the 2nd set of unbound fields would be UnboundDateOpenedStart2,
UnboundDateOpenedEnd2 & UnboundFileNo2 :
Thanks for any help ahead of time
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
If Not IsNull(Me.UnboundDateOpenedStart) Then
strWhere = strWhere & "([OpenDate] >= " &
Format(Me.UnboundDateOpenedStart, conJetDate) & ") AND "
End If
If Not IsNull(Me.UnboundDateOpenedEnd) Then
strWhere = strWhere & "([OpenDate] <= " &
Format(Me.UnboundDateOpenedEnd, conJetDate) & ") AND "
End If
If Not IsNull(Me.UnboundFileNo) Then
strWhere = strWhere & "([FileNum] like """ & Me.UnboundFileNo & """)
AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub