Trying to show all records after running a command...

  • Thread starter Thread starter h.a. collins
  • Start date Start date
H

h.a. collins

Hello All,

I have a fairly simple Access 2000 DB with one table (Telephone--about
700 entries) and one form (Telephone Details).

So that I have the option of searching by phone number, I've created a
command button linked to a text box. This allows me to enter the phone
number, hit the button, and I go directly to that single record. This
seems to work fine (see VB code at end of message, if you're curious)
and is quite useful.

However, I'm realizing that I do not always want to use this search
command button, and would like to have another command button (or
macro) that will allow me to "see all records", so that I can either
scroll using the arrow keys or Filter by form. Since the command
button isn't a filter, the only way I can "see all records" again is
by closing out the form, and re-opening. This is a bit of a nuisance!

Any ideas, suggestions?
Thanks in advance for your insight~
heather
________________________________________
Private Sub cmdSearch_Click()

If IsNull(PhoneSearch) Then
MsgBox "Please enter your search criterion", vbExclamation
Else
PhoneSearch.SetFocus
RecordSource = "SELECT * FROM Telephone WHERE Telephone_1 = '"
& PhoneSearch.Text & "';"
End If

End Sub

________________________________________
 
Instead of putting your Where condition in the SQL statement, you could use
the Filter Property:

Filter = "Telephone_1 = '" & PhoneSearch.Text & "'"
FilterOn = True

You can then use a command button to set the filter to a Null String, or set
the FilterOn property to False (keeps the statement in the Filter).

Paul Johnson
 
Back
Top