Solved

MS Access Form Field Lookup

Posted on 2011-02-19
4
370 Views
Last Modified: 2012-05-11
Hi all,

I am hoping someone out there knows a quick and easy answer to the following:

I have a form in MS Access.
I have a combo box on the form to select a username from a table called staff.
I want to select an entry in the above combo box and get it to auto-populate the text boxes named firstname, lastname and extension.

It sounds easy but is driving me crazy!!

Many thanks.
0
Comment
Question by:Howco
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 34933258
There are two possibilities here:  

1.  Put the firstname, lastname and extension field in the row source of the combo box (with 0 width columns), then, from the combo box's AfterUpdate event, write their values to the appropriate controls using this syntax:

Me![txtLastNameFirst] = Me![cboSelect].Column(1)
(numbering is zero-based, so Column(1) is the 2nd column)

2.  Make the textboxes on the form unbound, and give them control sources referencing columns of the combo box, like this:

=Me![cboSelect].Column(2)

#2 is generally better, since it is a violation of normalization to have the same data in different tables (apart from key fields).
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 34933262
use this as the rowsource of the combo box

select username,firstname, lastname, extension from staff

set the following properties of the combo

column count  4
bound Column  1

now, use the afterupdate event of the combo to populate the textboxes

private sub combo0_afterupdate()

me.firstname=me.combo0.column(1)
me.lastname=me.combo0.column(2)
me.extension=me.combo0.column(3)

end sub
0
 

Author Comment

by:Howco
ID: 34933272
Thanks for you reply.

Sorry, I should have mentioned that the combobox gets its data from a table called staff with columns in the table for username (used for selction in the combo), firstname, lastname and extension.

So I would click the combo and select a username that has been sourced from the staff table and then want the text boxes to take up the other fields of the same record.

0
 

Author Closing Comment

by:Howco
ID: 34933304
Absolutely faultless solution!

All sorted.  Many thanks to you and the others who contributed ideas.

This is the perfect solution though.  Many thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now