Pulling values from columns in a combo box.

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
 
C

Clif McIrvin

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)'
 
K

Klatuu

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.
 
C

Clif McIrvin

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>
 

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