auto-select entry in combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I see a lot of posts here about combo boxes, but have not quite found my
problem yet... I swear I have seen this before, and I may even have used
this before, but cannot for the life of me find it!!!!

I have a combo box that fills according to a row source UNION query so that
the values in the combo box are:

col 1 col 2
0 <New Entry>
1 Entry 1
2 Entry 2

When the form opens, I want Entry 1 to be selected in the combo box.

What code do I use?
 
Easiest way to do this is set the value in the form's Load event; you can
use this line of code:

Me.ComboBoxName.Value = Me.ComboBoxName.ItemData(1)
 
Hi, Bill.

In the form's OnCurrent( ) event, try:

Me!cboNames = Me!cboNames.Column(0, 1)

.. . . where cboNames is the name of the combo box, 0 is the combo box's
bound column (numbering starts at zero), and 1 is the second row (numbering
starts at zero).

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Doh! That's probably not the event you want that code in. Please disregard
my suggestion of the OnCurrent( ) event and use the form's OnLoad( ) event.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top