i have a search form that user can access to a sublist of records by choosing the parameter in combobox. this wirk good for one of comboboxs but display the popup form to enter the parameter value and after inserting the criteria it doesnt work. code for find button:
and code for sensing the search criteria:
what is wrong in using the "filter". another thing is that the count of filtered record is displaying after two click on find button.
Code:
Private Sub cmdFind_Click()
Dim strfilter As String
On Error GoTo Err_
Me.sbfrmSearch.Form.FilterOn = False
Select Case searchItem
Case 1
strfilter = "[Old Tel No#]='" & CStr(Me.txtOldNumber.Value) & "'"
lblCount.Caption = strfilter & " ______case 1-----" & CStr(searchItem)
Me.sbfrmSearch.Form.Filter = strfilter
Case 2
strfilter = "[New Tel No#]='" & Me.txtNewNumber.Value & "'"
lblCount.Caption = strfilter & " _______case 2-----" & CStr(searchItem)
Me.sbfrmSearch.Form.Filter = strfilter
Case 3
strfilter = "[Last Name]='" & Me.txtLastName.Value & "'"
lblCount.Caption = strfilter & " _______case 3-----" & CStr(searchItem)
Me.sbfrmSearch.Form.Filter = strfilter
Case 4
strfilter = "[Station Code]='" & CStr(Me.cboJobtitle.Value) & "'"
lblCount.Caption = strfilter & " ________case 4-----" & CStr(searchItem)
Me.sbfrmSearch.Form.Filter = strfilter
lblCount.Caption = "case 4"
Case 5
strfilter = "[Job titles]='" & CStr(Me.cboSite.Value) & "'"
lblCount.Caption = strfilter & " _______case 5-----" & CStr(searchItem)
Me.sbfrmSearch.Form.Filter = strfilter
End Select
Me.sbfrmSearch.Form.FilterOn = True
lbltest.Caption = Me.sbfrmSearch.Form.Recordset.RecordCount
Sub_Resume:
Exit Sub
Err_:
MsgBox "Error Number: " & Err.Number & " " & Err.Description
End Sub
and code for sensing the search criteria:
Code:
Private Sub txtNewNumber_BeforeUpdate(Cancel As Integer)
txtOldNumber = Null
txtLastName = Null
cboJobtitle = Null
cboSite = Null
searchItem = 2
End Sub