Combo Box 2 Bound Columns?

Y

yator

Is it possible to save 2 fields from a Combo Box to the underlying table?
For example, if I had a Combo Box with the fields TestID and TestName and
want to save them both to associated fields in the table.
I know this is bad form, but have a unique situation.
thanks
 
J

John W. Vinson

Is it possible to save 2 fields from a Combo Box to the underlying table?
For example, if I had a Combo Box with the fields TestID and TestName and
want to save them both to associated fields in the table.
I know this is bad form, but have a unique situation.
thanks

You'll need to have a separate textbox bound to TestName, and use the
AfterUpdate event of the combo to "push" the name into the bound textbox:

Private Sub cboTest_AfterUpdate()
Me!txtTestName = Me!cboTest.Column(1)
End Sub

This assumes a two column combo (column 0 being the TestID, Column 1 the
name), bound to the TestID field, and a separate textbox named txtTestName.
 
J

Jeff Boyce

Why?! If you are already saving, say, the "ID" field from the combobox in
the table behind your form, you don't NEED to store a second field. Any
time you need to see the second field, use a query.

If you want to see the second field in the same form, John's approach let's
you push it into an unbound textbox on the form without having to save it in
any table.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Y

yator

Thanks John the push to a second text box works fine.
Jeff, to answer your question. The records for this database are imported
from odbc queries from another large system. The TestIDs and Test Names
change in that database frequently. I do not maintain that system and also do
not want to try and keep up with the changes, I just need the ID and Name
when I need it.
thanks
 

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