Simple Question about Combo Box

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

I'm not completely sure what you are looking for here.

If you need to have the text of a textbox equal to the
second column of the combo box, then you just have, in code:

me.[txtboxname] = me.[cboboxname].column(1)
-remember to leave out the "[]'s" and that the first column
is column 0 and the second is column 1 (and so on) for a
list box or text box.

I'm not exactly sure, however, why you have 2 tables with
duplicate information. If you are going to have an ID for
the department, it needs to be in the department
information table. If table "A" as you called it, is the
table you are inputting the information to, then it does
need it's own table, and I am mistaken. Otherwise, you
need to merge these two tables into one.
 
Matt,
thanks for your reply. I've thought about it and its
not importnat that the dept name is recorded in the main
table. Its more important that I display the associated
name when I select the number from the combo box. So
what you've described sounds good. But I'm having
problems getting it to work. I created a combo box with
the two columns using the wizard to allow me to select a
dept number and the associated name. I want the text box
next to the combo box to display the dept name that is
listed in the 2nd column. Where do I put that line from
your first post? I tried putting it as the default value
of the text box but it did not display anything.
Sorry for my ineptitude but I'm very new at Access. I
really appreciate your assistance!
 
No problem. We all start Somewhere!

If you double click on the combo box, it will pop up the
properties of the combo box. Within that, you click the
"Event" tab. In there, you will click on the AfterUpdate
line, which will show up three dots next to that (similar
to a browse seach thing). Click the three dots. This will
open the coding window and will prepare it for you to input
code into the thing.

This is where you put that code that I typed.

It will look like this (after you type in it):

Private Sub [cboBoxName]_AfterUpdate()

me.[txtBoxName] = me.[cboBoxName].Column(1)

End Sub

You will want to remove everything inside the parenthises
after "AfterUpdate" so that it looks like the above example.

Good Luck!
 
Back
Top