Default value in a combo box

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

Guest

I have a form with a combo box listing a series of values. Instead of a
NotInList routine, I would like to have a default value appear in the combo
box when a new form is opened so that the user can tab to the combo box and
either accept the default value or pull down the list to select a different
value. Any help appreciated.
Thanks,
Dan
 
You'll need to run code that sets the combo box value to the desired value.
If you want this to occur when the form opens, you could use the form's Load
event to do this. In the example below, I'm setting the combo box to the
first item in its list:

Private Sub Form_Load()
Me.ComboBoxName.Value = Me.ComboBox.ItemData(0)
End Sub
 
Ken:
I tried:
Private Sub Form_Load()
Me.SourceID.Value = Me.SourceID.ItemData(0)
End Sub

Doesn't work. Data is in table tblSource with 2 fields: SourceID and Source.
Combo looks at this table. Did I misinterpret your suggestion?
Thanks,
Dan
 
Is SourceID the name of the combo box? It shouldn't be, but if it is, use
this:

Me!SourceID.Value = Me!SourceID.ItemData(0)
 
What if you were not using user forms but a standard combo box. I have a
combo box that puts the value of the "list" in a cell that the cursor was in
when I double click it. But I would like to have a default value - any
suggestions.
 
Combo boxes are used on a form... so I'm confused by your description of
"not using user forms but in a standard combo box"?

More information, please.
--

Ken Snell
<MS ACCESS MVP>
 
Sorry, I am probably goofing up but I use a combo box from the control
toolbar on my normal spreadsheet -- no forms at all. I had to use this type
of box because of my double click thing and my active cell. I have since put
a default of "" in the drop down list. Should I be concerned about not using
the right box?
 
Now I am sure I'm confused... ACCESS does not have spreadsheets. Are you
working in EXCEL or ACCESS?
 
Ken,
I am sorry to have wasted your time. When I did the search I did not just
search the excel forum but all forums and never looked until you posed this
question. I promise I do have an IQ and I am intelligent -- apparently I
need more sleep - smile. Thanks for your time and sorry to have confused
you. :)
 
No waste of time.. .always productive to exchange information!

Good luck!
 
Ken,

This code works but it defaulted all of the past records to Pending also. I
was looking for the same thing so I am not the orignal poster. How do I get
all the original fields bck to the way they were and have a defualt set?
 

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

Back
Top