Pulling values from columns in a combo box.

  • Thread starter Thread starter Bretona10
  • Start date Start date
B

Bretona10

I have a combo box that is populated from a table. It has two columns. I want
to take the value from the second column and fill in a field elsewhere on the
form, on the afterupdate property. Right now i am using a macro to fill in
other fields, so would like to use the setvalue function in a macro.

Thank you,
Bret
 
Bret, I find the built-in helps useful, tho it took me some serious
time to figure out how to use them successfully!

I think you want the .column property of the combo box (assuming
that you cannot simply set the bound column property to 2).

I know how to use it in VBA code; guess I'm not sure in a macro.
I just looked and it wasn't in the expression builder list for one of
my combo boxes.

in any event, the column index counts from 0, so to use the 2nd
column you would use

Me.otherField = Me.yourComboBox.Columns(1) to get the value
of the 2nd column in the first row.

typing 'column property' in the help search box pulled up 'Properties
of list boxes, combo boxes, (etc)'
 
This is a good place to start learning VBA. It is simple and, in this case,
easier than using a macro.
Use the After Update event of the combo. Clif is correct in his advise
except a minor syntax error, it is Column without an S.

As you progress, you will be more and more frustrated with the limitiations
of macros. One easy way to start understanding VBA is to convert a macro to
VBA and compare the macro to the code.
Macro's have limits. Error trapping is almost impossible.
You will find that most professionals very seldom, if ever, use them.
 
This is a good place to start learning VBA.  It is simple and, in this case,
easier than using a macro.
Use the After Update event of the combo.  Clif is correct in his advise
except a minor syntax error,  it is Column without an S.

Minor, but definately critical!

Thanks for catching it <g>
 
Back
Top