Solved

MS Access Form Field Lookup

Posted on 2011-02-19
4
389 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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