theinviter
Registered User.
- Local time
- Today, 07:06
- Joined
- Aug 14, 2014
- Messages
- 253
Dears;
I Have created a Form " 6-Inventory_Data" and on the top of the form added 2 Combo box and 2 fields for date selection, once I applied below code it did not work.
can you please guide me;
Private Sub filterThisForm8()
Dim S1, S2
On Error GoTo errhandler
'n = 1 / 0 ' cause an error
S1 = ""
If Len(Me!Combo_Category & "") <> 0 Then
S1 = S1 & " and [Category] Like '*" & Me!Combo_Category & "*' "
End If
If Len(Me!Combo_Items & "") <> 0 Then
S1 = S1 & " and [Items] Like '*" & Me!Combo_Items & "*' "
End If
If Len(Me!Combo101 & "") <> 0 Then
S1 = S1 & " and [Date_] >= #" & Format(Nz(Me.Date_From, 1), "yyyy\/mm\/dd") & "# AND [Date_] <= #" & Format(Nz(Me.Date_To, 2958465), "yyyy\/mm\/dd")
End If
If Len(S1) > 5 Then
S1 = Mid(S1, 5)
With Me.Form
.Filter = S1
.FilterOn = True
End With
Else
Me.Form.FilterOn = False
End If
Exit Sub
errhandler:
' error handling code
Resume Next
End Sub
I Have created a Form " 6-Inventory_Data" and on the top of the form added 2 Combo box and 2 fields for date selection, once I applied below code it did not work.
can you please guide me;
Private Sub filterThisForm8()
Dim S1, S2
On Error GoTo errhandler
'n = 1 / 0 ' cause an error
S1 = ""
If Len(Me!Combo_Category & "") <> 0 Then
S1 = S1 & " and [Category] Like '*" & Me!Combo_Category & "*' "
End If
If Len(Me!Combo_Items & "") <> 0 Then
S1 = S1 & " and [Items] Like '*" & Me!Combo_Items & "*' "
End If
If Len(Me!Combo101 & "") <> 0 Then
S1 = S1 & " and [Date_] >= #" & Format(Nz(Me.Date_From, 1), "yyyy\/mm\/dd") & "# AND [Date_] <= #" & Format(Nz(Me.Date_To, 2958465), "yyyy\/mm\/dd")
End If
If Len(S1) > 5 Then
S1 = Mid(S1, 5)
With Me.Form
.Filter = S1
.FilterOn = True
End With
Else
Me.Form.FilterOn = False
End If
Exit Sub
errhandler:
' error handling code
Resume Next
End Sub