How to read a specific column in a multi-column combo box?

D

David G.

I have a combo box with a record source that consists of several
columns. The combo box rightly displays the column I want seen;
however, there is a second column that I would like to display in a
text box.

I know I could join the 2 columns together in the source query, but I
would prefer to display the 2nd value separately.

I created a user-defined function that fills the text box from an SQL
statement, but it takes almost a full second to complete. (That's only
with a dozen or so records.)
code snippet
Set db = CurrentDb
strSQL = "SELECT tblMaterial.tblMaterialID,
tblMaterial.tblMaterialSUDZZ " & _
"FROM tblMaterial " & _
"WHERE (((tblMaterial.tblMaterialID)= " &
lngMaterial & "));"

Set rs = db.OpenRecordset(strSQL, dbReadOnly)
UDF=rs![tblMaterialSUDZZ]
end of snippet

Is there some expression like:
=[comboControl1].[columnName]
that can be used in a textboxes control source?
THANKS!
David G.
 
D

Duane Hookom

You should be able to do this without any code. Try use a text box with a
control source like:
=comboControl1.Column( X )
X is the number of the column to display and is zero-based.
 
D

David G.

PERFECT!

I thought there was a way, but couldn't find any reference!

THANKS!
You should be able to do this without any code. Try use a text box with a
control source like:
=comboControl1.Column( X )
X is the number of the column to display and is zero-based.
THANKS!
David 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