AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Automatically filling fields on forms

Using MS Access - Automatically filling fields on forms


Expert: Scottgem - 3/28/2004

Question
Could you help me with a combo box I have on a form. When I select the value in the combo box I want to automatically fill in unbound boxes in the form to give the details not in the combo box. I have done this before and for the life of me I cannot remember how to do it. e.g. if I select a value London from a combo box with two fields London and England, how can I put England automatically into another field. Any help greatly appreciated.

Answer
There are a few ways to do this. If there are a lot of controls to populate, then I would use a subform linked to the combobox value.

If there are only 1 or 2 controls to populate then I would recommend using the columns property. What you do is expand the query behind the combobox to include columns for the other pieces of data you want to display. You can set the Column widths property so these columns don't show. Then use the After Update event to ppopulate the control. For example:

Me!Country = Me!cboCity.Column(2)

The columns start counting at 0 so Country would be the 3rd column (1st col is primary key, 2nd is city name). You can use the same code in the On Current event to populate the controls as you browse.

The alternative is using DLookups as the datasource of the unbound controls.

Hope this helps,
Scott<>

Please don't forget to provide feedback for this response (either by rating or followup). It helps me help people better if I know how my advice worked.

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.