By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
461,986 Members | 466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 461,986 IT Pros & Developers. It's quick & easy.

Fill field based on another field??

100+
P: 135
Ok.
I have a form with a field for a sampler's name, number, and email address. The sampler's name is selected from a combo box that references a table with name, number, and email. I want to be able select the name in the combo box and have the fields for the phone number and email address fill with the selected sampler's info. I have tried setting the control source of another combo box (for the email address) to the samplers name combo box. This does show the email address, but when I try to use that for my email it comes in as the Sampler's Name (primary ID) instead of the address. HELP?
Nov 15 '08 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,545
Hi. The unseen columns of the combo list are available using the Column property of the combo box control. Columns are numbered starting from 0. Column 0 is normally the combo's bound value and is the one referred to by default when you reference the combo directly as you have found out.

All you need to do is work out which column you need and use the Column property to get the value. If it was the second column you would refer to it like this:

[yourcomboname].Column(1)

If you are setting the values of textboxes bound to underlying fields in your table such as an e-mail address, you can set their values using VBA code in the After Update event of the combo to reflect the change of selection as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub yourcomboname_afterupdate()
  2.    me![name of emailtextbox] = me![yourcomboname].column(1)
  3.    me![name of your number textbox] = me![yourcomboname].column(2)
  4. End Sub
You would of course need to replace the names and column positions with the right ones for your own application.

-Stewart
Nov 15 '08 #2

100+
P: 135
Hi. The unseen columns of the combo list are available using the Column property of the combo box control. Columns are numbered starting from 0. Column 0 is normally the combo's bound value and is the one referred to by default when you reference the combo directly as you have found out.

All you need to do is work out which column you need and use the Column property to get the value. If it was the second column you would refer to it like this:

[yourcomboname].Column(1)

If you are setting the values of textboxes bound to underlying fields in your table such as an e-mail address, you can set their values using VBA code in the After Update event of the combo to reflect the change of selection as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub yourcomboname_afterupdate()
  2.    me![name of emailtextbox] = me![yourcomboname].column(1)
  3.    me![name of your number textbox] = me![yourcomboname].column(2)
  4. End Sub
You would of course need to replace the names and column positions with the right ones for your own application.

-Stewart
Thanks Stewart. Seems to be just what I'm looking for.
Nov 16 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.