linking form and table

tamirka

New Member
Joined
Nov 7, 2002
Messages
40
I have 2 fields in a form. name and last name
i have a table called names in which I have all the names and last names.
when i open the form , I need to type in the name, the last name will automatically show up in the last name field
please help asap
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
tamirka,

Make a query from the names table. Open your form in design view. Set the forms record source to this query and the control source of the two controls to the name fields. In design view of the query, right click on the criteria field for 'name', select built|expression builder|open forms, and find the control on this form that will hold the name. Save and close the query.

On your form, right click on the textbox that will have the name, select build event, and enter this code:

Code:
sub txt1_afterupdate()

me.requery

end sub

with txt1 being the name of the control that will receive the name for which you want to search.

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,522
Messages
6,160,308
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top