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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookups that fill in multiple fields

Status
Not open for further replies.

slacker69

MIS
Oct 8, 2002
11
0
0
GB
Hi

Im pretty green with access so Im just wondering if this can be done and if it can how.

On a table I have a lookup which lists the field "user ID" numbers from a separate table, this table also contains fields "forename" and "surname". I want to be able to select a "user ID" from a combo box and have it fill in the "user ID" as well as the "surname" and "forename".

Im sure it can be done somehow, If anyone can help that would be great.

Thanks

Steve
 
Code:
Private Sub ComboBoxName_AfterUpdate()
    Me.txtFirstName = Me.ComboBoxName.Column(1)
    Me.txtLastName = Me.ComboBoxName.Column(2)
End Sub
With appropriate chages in controls name and index

________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
I am working on a project with similar requirements but I am a Access noob and my skills are limited to creating basic tables and forms.

I have a database with two tables, 'Proposal' and 'Customer'. In a form, I have a combo box that lists the values for 'name' from the 'Customer' table. When I select a name from the combo box, I want the next field, 'city', to fill with data from the appropriate city column in the 'customer' table. I know there are solutions to this on this board, but I don't know how to apply them.

ZmrAbdulla, Where am I supposed to apply the code you list here?

Can anybody recommend a good learning resource for Access noobs? I've been through the training classes online at microsoft.com and have the Steve Schwartz 'Microsoft Access For Windows 2003' visual quickstart guide, but that doesn't cover things I need to be able to do.
 
Suppose you have a combo box named "ComboCustomer". It's Rowsource will be something like
Code:
Select Customer.CustomerName,Customer.City From Customer;
And you have a textBox called "CustomerCity".
You need to add the code AfterUpdate Event of the "ComboCustomer".
Code:
Private Sub ComboCustomer_AfterUpdate()
    Me.CustomerCity = Me.ComboCustomer.Column(1)
End Sub
hope this helps

________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top