Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text box for search

Status
Not open for further replies.

morg27

MIS
Feb 4, 2002
16
US
I am creating a registration database and there will be almost 900 records. I want to be able to search those records within the current record form by last name. How do I do that using a text box and command button?
 
see this faq under this forum, uses a combo box but should be easily applied to a text box

faq702-4398
 
I would prefer not to use a combo box as their will be 900 or so choices. I would like to have the user be able to search for records by a last name.
 
morg27
If you are interested in a way to populate either a list box or a combo box with just the records you want to see, and select the records you want to see by entering a value in a text box, here is a method...

1. Create a text box which you will use to enter the search criteria for the combo box. Let's call it txtSearch.

2. Create a combo box which will look up values in your table. Let's call it cboSearch.

3. Open the SQL behind the combo box. In the field upon which you want to do the search, in your case LastName, put
Like Forms!yourFormName!txtSearch & "*"

4. In the forms Current event, put Me.cboSearch = Null. This will empty the combo box each time the form is updated.

5. In the AfterUpdate event for the txtSearch text box, put...
Me.cboSearch.Requery (so that the combo box gets requeried each time the text box is updated)

Tom
 
Now when I have records which have the same value for last name. Then what?
 
morg27
Okay, let's assume that you have 2 additional fields in the table through which you are searching. Those two fields would be RecordID and FirstName. Typically, the RecordID field would be hidden, so the combo, or list, box results would be something such as...
Brown, Cedric
Brown, James
Brown, Samuel

That would allow you to select the last name you wanted, by the match with the first name.

What you do from there on depends on what you want to do. Print a report, or something else? Go to that person's records?

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top