Search Button

damdoumaa

Registered User.
Local time
Today, 01:16
Joined
Apr 23, 2004
Messages
16
Hi Everybody,

This is about a contact database.

I have a textbox and a search button.

I want the user to type in the last name into the textbox and hit search. The results should appear in a subform that I have already created. this subform reads all the info that I want from the table that I want.

How to I set up the 'Onclick' event of the button?

Thank you.
 
Is there anything in your main form other than the text box and the command button?

The reason I ask is that the correct way to do this would be to have a combo box with a list of all the names, and as you select a name or type a name into the box, the form will automatically bring up all of the fields in that record.
 
No, I only have this text box and the command button.

You're right a combo box would be better. I might change it into combo box later on.

Either way, the command button, OR the combo box would have the same code on "OnChange" or "OnClick" events, that changes whatever is in the subform when either the combo box value is changed or the command button is pressed. This is the code that I would like to know!

Thank you.
 
For what you are doing, a subform is not necessary and can complicate things. I would suggest moving your text box and command button to the subform, and then using that as your only form.

Here is a link to a recent thread that discusses ways to auto fill fields on a form using a combo box. I am waiting for an answer on that thread regarding using a query to do it. You would not be able to use the column() method for a text box but the recordset filtering method would work for what you are doing. If you search the forum you can probably find more answers as well.

http://www.access-programmers.co.uk/forums/showthread.php?t=64963

Good luck.
 
Search Help

Hi All
Using access 2000
I have a Contact table with around 600 entries that I would like to be able search by Surname then Given name. I would like to then click on the result to open the data entry form associated to the table. Any Ideas as to how I can manage this would be great – I know I will need to create a form called search with 2 textboxes for user to enter Surname and Givenname and a command button called search. This is where I get lost to know where to go from here – what code will do this and how to display the result so that I can then click to get the data entry form to open.

I have been searching and the examples I have found - I can't seem to adapt - Please Help

getting desperate now
 
Danson,

I am going to make a few assumptions about how you want this to work.

As an example, when you enter "Smith" for surname and "John" for given name you want the data entry form to open up with the matching record?

Put your surname and given name unbound textboxes right on the data entry form. You really don't need 2 forms. Name the text boxes txtSurname and txtGivenName.

Design a query based on your table. In the criteria for the surname field enter a reference to the textbox control your form:

[Forms]![YourFormName]![txtSurname]

Do the same for the given name field.

Use this query as the record source for your form and set up the command button event with this code:

Me.Requery

Now when you enter the 2 names and click the button, the form will pull up the related record.

The recommended way to do this is to use combo boxes for the names. You may want to look into that option.

Good luck.
 
Rich-O,

I would like to do a similar sort of thing.

I want to have text box where you can type in a keyword (I also have combo box doing the same thing but i would like to have two options for the users.)

After typing in the keyword, I would like the results (which will be file names) to appear in the second combo box. The user would select the resulting file names, and the records would appear in the fields below.

If no records come up, I would like a message box saying something like, "no records were found" or something like that.

binghamw
 

Users who are viewing this thread

Back
Top Bottom