Hi,
I have multiple combo boxes at the top of a form which are used to filter records in the details section of the form.
I have a procedure called FilterCommand which is called everytime one of the combo boxes is updated (afterupdate event) Here is the procedure:
Now the problem is that lets say a user selects a value from cboWatts which returns 5 records. Now the user selects a value from cboVolts (making the filter cbovolts and cboWatts) If there are no records which meet this filter the cboVolts combobox displays nothing (It appears to display nothing but in fact in the text in the box is just invisible).
Is there some way to improve how I am filtering these records? or modify my code so the value of the box will not be invisible if the filter does not return any records?
Any suggestions would be greatly appreciated. Thanks!
I have multiple combo boxes at the top of a form which are used to filter records in the details section of the form.
I have a procedure called FilterCommand which is called everytime one of the combo boxes is updated (afterupdate event) Here is the procedure:
Code:
Private Sub FilterCommand()
Dim strFilter As String
strFilter = "1 = 1"
If Len(cboInternalCode) > 0 Then
strFilter = strFilter & " AND InternalCode='" & cboInternalCode & "'"
End If
If Len(cboBallastType) > 0 Then
strFilter = strFilter & " AND ballasttype = " & cboBallastType
End If
If Len(cboInput) > 0 Then
strFilter = strFilter & " AND InputWatts = " & cboInput
End If
If Len(cboType) > 0 Then
strFilter = strFilter & " AND Type =" & cboType
End If
If Len(cboLampType) > 0 Then
strFilter = strFilter & " AND lamptype = '" & cboLampType & "'"
End If
If Len(cboBase) > 0 Then
strFilter = strFilter & " AND base = '" & cboBase & "'"
End If
If Len(cboWatts) > 0 Then
strFilter = strFilter & " AND watts = '" & cboWatts & "'"
End If
If Len(cboVolts) > 0 Then
strFilter = strFilter & " AND volts = '" & cboVolts & "'"
End If
Me.Filter = strFilter
Me.FilterOn = True
End Sub
Now the problem is that lets say a user selects a value from cboWatts which returns 5 records. Now the user selects a value from cboVolts (making the filter cbovolts and cboWatts) If there are no records which meet this filter the cboVolts combobox displays nothing (It appears to display nothing but in fact in the text in the box is just invisible).
Is there some way to improve how I am filtering these records? or modify my code so the value of the box will not be invisible if the filter does not return any records?
Any suggestions would be greatly appreciated. Thanks!