Solved

MS Access Form Field Lookup

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 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

23 Experts available now in Live!

Get 1:1 Help Now