hi, i was wondering if someone can help me, i have a form, with an unbound text box and a command button (code below) that searches through the underlying table and filters the results to show only what i searched for. What i would like, is another command button that after i do a search, it shows all of the records in the table again. hopefully that makes sense... any ideas? thanks!
Code:
Private Sub Command47_Click()
Dim strStudentRef As String
Dim strSearch As String
Dim strSql As String
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![acctsearch]) Or (Me![acctsearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![acctsearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in Address
DoCmd.ShowAllRecords
'Chr(42)is ascii code for the wildcard symbol
strSql = "Select * from [Meters] Where Acct Like '" & Chr(42) & Me!acctsearch & Chr(42) & "';"
Me.RecordSource = strSql
'If one or more matching records are found, they can be displayed one at a time via the navigation buttons
If Me.Recordset.RecordCount > 0 Then
acctsearch.SetFocus
strSearch = acctsearch.Text
acctsearch.SetFocus
strSearch = acctsearch.Text
MsgBox "Match Found For: " & strSearch
acctsearch = Null
'If value not found sets focus back to txtSearch and shows msgbox
Else
acctsearch.SetFocus
strSearch = acctsearch
MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
, "Invalid Search Criterion!"
acctsearch.SetFocus
End If
End Sub
Comment