fill a field from a combobox

P

Pierkes

Hi,

I have a userform with a sourcetable "houses". On the form is a combobox
(source is a query with Broker_ID and BrokerName and BrokerEmail) with which
i select the a broker.
When a value in the combobox is selected (Brokername), i would like another
field (Email) on the form to be filled with the value in the second
column(BrokerEmail) of the combobox.
The source of the Email field is in the houses table.

Can anyone give me VBcode to do this ?
Thanks,
Pierre
 
S

Steve

Column numbers in a combobox start with 0 so email is in column 2.

Me!Email = Me!NameOfCombobox.Column(2)

Steve
(e-mail address removed)
 
A

Al Campagna

Pierkes,
Use an unbound calculated text control with a Control Source of...
= cboBrokerName.Column(1)
It will always display the associated email address for the BrokerName
selected in the combo.
Combo columns are numbered 0, 1, 2, 3, etc...
So, column 2 is actually referred to as Column(1)

However... selecting a Broker by BrokerName is not really a good thing
to do. Each Broker should have a unique identifier key value, like a
BrokerID.
And... that's how they should be selected...
Even though you might not have brokers with the same name now, the
possibility
exists. Always try to program for "never happen" instead of "might happen."
--
hth
Al Campagna
Microsoft Access MVP 2006-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
S

Steve

Hello Al,

From the OP's post:
<<On the form is a combobox (source is a query with Broker_ID and BrokerName
and BrokerEmail) >>

BrokerEmail is in the third column.

I have learned a lot reading your responses in the newsgroup.

Have a good evening!!!

Steve
 
A

Al Campagna

OK Steve,
I missed the part about having the ID in there too...
Most of the time, when OPs refer to the second column I assume
they mean the second from left. But he rightly used it to signify the third
column from the left.
I see what you mean now...
Al Campagna
 
S

Steve

Hi Al,

Thanks for coming back!

Steve


Al Campagna said:
OK Steve,
I missed the part about having the ID in there too...
Most of the time, when OPs refer to the second column I assume
they mean the second from left. But he rightly used it to signify the
third
column from the left.
I see what you mean now...
Al Campagna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top