| If you want to create a Search Box
for names or other data, you can use the following techniques:
For this example, we will search a field called [lastname].
The form will have a table of contacts ("Contacts") as its Record Source.
In the form footer (or header), create an unbound text
box. Call it "EnterLastNameTxt".
Create a Search button with one of the following On Click Procedure:
For text* searches:
DoCmd.ApplyFilter , "[LastName] like """ & Me![EnterLastNameTxt] & "*"""
For *text* searches:
DoCmd.ApplyFilter , "[LastName] like """ & "*" & Me![EnterLastNameTxt] &
"*"""
You can then add a button that will open a form with all
the details of the record. You can use the Open Form wizard to create the
button. Make sure you use the "Open the Form and find specific data to
display" option. You will need the key field to be in both forms, even if
you hide it in either one.
As the commands above are filters, you will want a way
to show all the records again. A button with the following code will do:
DoCmd.ShowAllRecords
Ideally, make the form a pop-up form, and add a Count
control by using the following expression in a control:
=Count([contactid]) & " names"
The example below also has the search on a [company]
field:

|