Filters not responding

H

Hiro

Hello Forum Members:

I have the following filters on the form and found out some filters are not
working while the other filters are working.
The filters that are NOT working are:
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
If Not IsNull(Me.FindSize1) Then
strWhere = strWhere & "([JawsSize] >= " & Format(Me.FindSize1) & ")
AND "
End If

If Not IsNull(Me.FindSize2) Then 'Less than the next day.
strWhere = strWhere & "([JawsSize] < " & Format(Me.FindSize2 + 1) &
") AND "
End If

If Not IsNull(Me.FindLength1) Then
strWhere = strWhere & "([Length] >= " & Format(Me.FindLength1) & ")
AND "
End If

If Not IsNull(Me.FindLength2) Then 'Less than the next day.
strWhere = strWhere & "([Length] < " & Format(Me.FindLength2 + 1) &
") AND "
End If
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
What am I doing wrong? Can anybody see what is causing this problem?

And this the entire code.
[starts here.]
Private Sub cmdFilter_Click()

Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.FindCompany) Then
strWhere = strWhere & "([CompanyName] Like " & Me.FindCompany & ")
AND "
End If

If Not IsNull(Me.FindProduct) Then
strWhere = strWhere & "([ProductName] Like " & Me.FindProduct & ")
AND "
End If

If Not IsNull(Me.FindVolume) Then
strWhere = strWhere & "([JawsVolume] Like " & Me.FindVolume & ") AND "
End If

If Not IsNull(Me.FindSize) Then
strWhere = strWhere & "([JawsSize] Like " & Me.FindSize & ") AND "
End If

If Me.cboFilterFenestrated = 0 Then
strWhere = strWhere & "([JawsFenestrated] = True) AND "
ElseIf Me.cboFilterFenestrated = 1 Then
strWhere = strWhere & "([JawsFenestrated] = False) AND "
End If

If Not IsNull(Me.FindSheath) Then
strWhere = strWhere & "([SheathSize] Like " & Me.FindSheath & ") AND "
End If

If Not IsNull(Me.FindLength) Then
strWhere = strWhere & "([Length] Like " & Me.FindLength & ") AND "
End If

If Me.cboFilterFormable = 0 Then
strWhere = strWhere & "([Formable] = True) AND "
ElseIf Me.cboFilterFormable = 1 Then
strWhere = strWhere & "([Formable] = False) AND "
End If

If Me.cboFilterFEP = 0 Then
strWhere = strWhere & "([FEP] = True) AND "
ElseIf Me.cboFilterFEP = 1 Then
strWhere = strWhere & "([FEP] = False) AND "
End If

If Not IsNull(Me.FindSize1) Then
strWhere = strWhere & "([JawsSize] >= " & Format(Me.FindSize1) & ")
AND "
End If

If Not IsNull(Me.FindSize2) Then 'Less than the next day.
strWhere = strWhere & "([JawsSize] < " & Format(Me.FindSize2 + 1) &
") AND "
End If

If Not IsNull(Me.FindLength1) Then
strWhere = strWhere & "([Length] >= " & Format(Me.FindLength1) & ")
AND "
End If

If Not IsNull(Me.FindLength2) Then 'Less than the next day.
strWhere = strWhere & "([Length] < " & Format(Me.FindLength2 + 1) &
") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Nothing is specified.", vbInformation, "Nothing to show."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True
End If

End Sub
[ends here.]

With best regards,
Hiro
 
M

Maurice

Seems like you are formatting your field in the filter. If needed supply the
format arguments otherwise leave the format out.

hth
--
Maurice Ausum


Hiro said:
Hello Forum Members:

I have the following filters on the form and found out some filters are not
working while the other filters are working.
The filters that are NOT working are:
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
If Not IsNull(Me.FindSize1) Then
strWhere = strWhere & "([JawsSize] >= " & Format(Me.FindSize1) & ")
AND "
End If

If Not IsNull(Me.FindSize2) Then 'Less than the next day.
strWhere = strWhere & "([JawsSize] < " & Format(Me.FindSize2 + 1) &
") AND "
End If

If Not IsNull(Me.FindLength1) Then
strWhere = strWhere & "([Length] >= " & Format(Me.FindLength1) & ")
AND "
End If

If Not IsNull(Me.FindLength2) Then 'Less than the next day.
strWhere = strWhere & "([Length] < " & Format(Me.FindLength2 + 1) &
") AND "
End If
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
What am I doing wrong? Can anybody see what is causing this problem?

And this the entire code.
[starts here.]
Private Sub cmdFilter_Click()

Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.FindCompany) Then
strWhere = strWhere & "([CompanyName] Like " & Me.FindCompany & ")
AND "
End If

If Not IsNull(Me.FindProduct) Then
strWhere = strWhere & "([ProductName] Like " & Me.FindProduct & ")
AND "
End If

If Not IsNull(Me.FindVolume) Then
strWhere = strWhere & "([JawsVolume] Like " & Me.FindVolume & ") AND "
End If

If Not IsNull(Me.FindSize) Then
strWhere = strWhere & "([JawsSize] Like " & Me.FindSize & ") AND "
End If

If Me.cboFilterFenestrated = 0 Then
strWhere = strWhere & "([JawsFenestrated] = True) AND "
ElseIf Me.cboFilterFenestrated = 1 Then
strWhere = strWhere & "([JawsFenestrated] = False) AND "
End If

If Not IsNull(Me.FindSheath) Then
strWhere = strWhere & "([SheathSize] Like " & Me.FindSheath & ") AND "
End If

If Not IsNull(Me.FindLength) Then
strWhere = strWhere & "([Length] Like " & Me.FindLength & ") AND "
End If

If Me.cboFilterFormable = 0 Then
strWhere = strWhere & "([Formable] = True) AND "
ElseIf Me.cboFilterFormable = 1 Then
strWhere = strWhere & "([Formable] = False) AND "
End If

If Me.cboFilterFEP = 0 Then
strWhere = strWhere & "([FEP] = True) AND "
ElseIf Me.cboFilterFEP = 1 Then
strWhere = strWhere & "([FEP] = False) AND "
End If

If Not IsNull(Me.FindSize1) Then
strWhere = strWhere & "([JawsSize] >= " & Format(Me.FindSize1) & ")
AND "
End If

If Not IsNull(Me.FindSize2) Then 'Less than the next day.
strWhere = strWhere & "([JawsSize] < " & Format(Me.FindSize2 + 1) &
") AND "
End If

If Not IsNull(Me.FindLength1) Then
strWhere = strWhere & "([Length] >= " & Format(Me.FindLength1) & ")
AND "
End If

If Not IsNull(Me.FindLength2) Then 'Less than the next day.
strWhere = strWhere & "([Length] < " & Format(Me.FindLength2 + 1) &
") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Nothing is specified.", vbInformation, "Nothing to show."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True
End If

End Sub
[ends here.]

With best regards,
Hiro
 
H

Hiro

Thank you for looking into this, Maurice.

I figured it out. On the table, I used the wrong data type. It as a text and
it should have been number. So I corrected these mistakes. No wonder it
didn't work on "Format(Me.FindSize2 + 1) " section. Now every thing is
working.

With best regards,
Hiro

Maurice said:
Seems like you are formatting your field in the filter. If needed supply the
format arguments otherwise leave the format out.

hth
--
Maurice Ausum


Hiro said:
Hello Forum Members:

I have the following filters on the form and found out some filters are not
working while the other filters are working.
The filters that are NOT working are:
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
If Not IsNull(Me.FindSize1) Then
strWhere = strWhere & "([JawsSize] >= " & Format(Me.FindSize1) & ")
AND "
End If

If Not IsNull(Me.FindSize2) Then 'Less than the next day.
strWhere = strWhere & "([JawsSize] < " & Format(Me.FindSize2 + 1) &
") AND "
End If

If Not IsNull(Me.FindLength1) Then
strWhere = strWhere & "([Length] >= " & Format(Me.FindLength1) & ")
AND "
End If

If Not IsNull(Me.FindLength2) Then 'Less than the next day.
strWhere = strWhere & "([Length] < " & Format(Me.FindLength2 + 1) &
") AND "
End If
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
What am I doing wrong? Can anybody see what is causing this problem?

And this the entire code.
[starts here.]
Private Sub cmdFilter_Click()

Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.FindCompany) Then
strWhere = strWhere & "([CompanyName] Like " & Me.FindCompany & ")
AND "
End If

If Not IsNull(Me.FindProduct) Then
strWhere = strWhere & "([ProductName] Like " & Me.FindProduct & ")
AND "
End If

If Not IsNull(Me.FindVolume) Then
strWhere = strWhere & "([JawsVolume] Like " & Me.FindVolume & ") AND "
End If

If Not IsNull(Me.FindSize) Then
strWhere = strWhere & "([JawsSize] Like " & Me.FindSize & ") AND "
End If

If Me.cboFilterFenestrated = 0 Then
strWhere = strWhere & "([JawsFenestrated] = True) AND "
ElseIf Me.cboFilterFenestrated = 1 Then
strWhere = strWhere & "([JawsFenestrated] = False) AND "
End If

If Not IsNull(Me.FindSheath) Then
strWhere = strWhere & "([SheathSize] Like " & Me.FindSheath & ") AND "
End If

If Not IsNull(Me.FindLength) Then
strWhere = strWhere & "([Length] Like " & Me.FindLength & ") AND "
End If

If Me.cboFilterFormable = 0 Then
strWhere = strWhere & "([Formable] = True) AND "
ElseIf Me.cboFilterFormable = 1 Then
strWhere = strWhere & "([Formable] = False) AND "
End If

If Me.cboFilterFEP = 0 Then
strWhere = strWhere & "([FEP] = True) AND "
ElseIf Me.cboFilterFEP = 1 Then
strWhere = strWhere & "([FEP] = False) AND "
End If

If Not IsNull(Me.FindSize1) Then
strWhere = strWhere & "([JawsSize] >= " & Format(Me.FindSize1) & ")
AND "
End If

If Not IsNull(Me.FindSize2) Then 'Less than the next day.
strWhere = strWhere & "([JawsSize] < " & Format(Me.FindSize2 + 1) &
") AND "
End If

If Not IsNull(Me.FindLength1) Then
strWhere = strWhere & "([Length] >= " & Format(Me.FindLength1) & ")
AND "
End If

If Not IsNull(Me.FindLength2) Then 'Less than the next day.
strWhere = strWhere & "([Length] < " & Format(Me.FindLength2 + 1) &
") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Nothing is specified.", vbInformation, "Nothing to show."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True
End If

End Sub
[ends here.]

With best regards,
Hiro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top