VBA code for unbound column in combo box

A

Amanda

In an animal management database, I have a form where a combo box offers
selections of all the species in the species table. The combo box displays
the species name (my 2nd column), but the value of the combo box is bound to
the species ID (the 1st column, 0" width).

I need to use the species name to pass on to a report generated by this
form, but currently when I call Me.Species_Name (name of the combo box) I get
the species ID (which is nice for other things I am doing). Can I call the
value of the unbound column for the same record?

Thanks, Amanda
 
D

Douglas J. Steele

To get the value of the second column of the selected row of the combo box,
use

Me.Species_Name.Column(1)

(The Column collection starts numbering at 0)
 
A

Allen Browne

If you just want to refer to column 2 of the combo on the form, you could
put something like this in the Control Source of a text box on your report:
=[Forms].[Form1].[Species_Name]

If you need to get the species name matching each entry in the report, you
will need to use a query as the source for the report. Include the lookup
table in that query (i.e. the table that supplies the RowSource for the
combo.) You can then get at the field that contains the names.
 
A

Amanda

Thanks! That was easy.

Douglas J. Steele said:
To get the value of the second column of the selected row of the combo box,
use

Me.Species_Name.Column(1)

(The Column collection starts numbering at 0)
 

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