I need to create a database search form

  • Thread starter Thread starter eBradleyGT
  • Start date Start date
E

eBradleyGT

I have created a database for the 130 properties that i manage in one table
with general info, staff, emergency contact, and sales and leasing
information. I want to create some sort of search box (not using the cntrl+F
find feature) where my receptionists can quickly enter the name of the
property a customer is calling from and the form I have designed will pop up
with all the pertinent information on that property...Thanks for any help.
 
You can do it all in one form, and by using a combo box listing the
properties alphabetically avoid any discrepancies between the typed name and
the name in the table.

Create a form bound to the table (or better still a sorted query based on
the table) and add an unbound combo box with a RowSource property along these
lines:

SELECT PropertyName FROM Properties ORDER BY PropertyName;

Where PropertyName is the name of the field and Properties the name of the
table. In the AfterUpdate event procedure of the combo box put the following
code:

Dim rst As Object

Set rst = Me.Recordset.Clone

rst.FindFirst "[PropertyName] = " & [cboProperties]
Me.Bookmark = rst.Bookmark

where cboProperties is the name of the combo box. Ensure the AutoExpand
property of the combo box is set to True (Yes). A user will then be able to
start typing a name and the combo box will automatically show the first match
as each character is typed. When the user presses the Enter key or selects
an item from the list with the mouse the form will go to the selected
property record.

An added enhancement is to keep the unbound combo box in sync with the form
if the user navigates to a record by other means such as the built in
navigation bar. To do this put the following in the form's Current event
procedure:

Me.[cboProperties] = Me.[PropertyName]

Ken Sheridan
Stafford, England
 
Correction. As it will be text data type you need to wrap the value in
quotes like so:

rst.FindFirst "[PropertyName] = """ & [cboProperties] & """"

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top