How can I update a text box based on a column in a ComboBox?

G

Guest

Hello! I have a form with a combo box called District Name. The combo box
has two columns: District Name and Area Education Agency Name. I want to
fix it so that when the District name is chosen or typed in the combox box,
the corresponding Area Education Agency will appear in a text box. I can't
seem to get the code correct in the ControlSource for the text box, probably
because I'm only a lowly end user instead of a programmer. ;-) Anyway, any
help would be great!
 
G

Guest

Bow Down oh lowly and unworthy end user and be thankful a World Class Access
Ghuru with Unfathomable Knowledge has come to enlighten you :)

Sorry, sometimes I get really out of hand and have to be slapped back to
reality.

It is not the control source you need to use. It is the After Update event
of your combo box.

Me.UnNamedTextBox = Me.DistrictName.Column(1)

That's all there is to it. I am assuming Area Education Agency Name is in
the second column of your combo box. If so, the 1 is correct because column
numbers start with 0.

Notice I took the space out of District Name. Spaces and special characters
should not be used in names. Try to make it a habbit to use only Letters,
Numbers and the underscore for naming. I would recommend you change the name
from District Name to DistrictName. And, if you really want to develop good
naming habits, it would be cboDistrictName (cbo = Combo Box, txt = Text Box,
chk = Check Box, lst = List Box, cmd = Command Button, lbl = Label, for some
examples)
 
J

jahoobob via AccessMonster.com

Look at the Orders Form in the Northwind sample database. It
shows 2 different methods of filling a TextBox from the selection of a
ComboBox. The 2 methods are used differently: the Mailing
Address Controls are calculated and the Delivery
Address Controls are bound.
 
G

Guest

ThankyouThankyou .. THANK YOU!!! I've been banging my head against my
partition for the past hour trying to get this right. Have a super day!
 
G

Guest

Oops! Celebrated too soon. LOL! Getting an error message "Microsoft
Access can't find macro 'ME' think i missed something ...
 
G

Guest

Where did you put the code?
It should be in the After Update event of the combo box.

Open your form in design mode.
Select the combo box and Right Click.
Select properties.
In the properties dailog, select the Events tab
In the After Update event, click the command button with the 3 dots
Select Code Builder
Paste the code there and make any changes you need to match your names.

The Me. always means the current form.
 

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