Auto-select combo box entry when only one row

  • Thread starter Thread starter mscertified
  • Start date Start date
M

mscertified

I have 2 combo boxes the second is dependent on the first. When the first is
clicked, I requery the second in the OnClick event. When the requeried combo
box has only one row, I'd like this to be auto selected. How can I do this?
Thanks.
 
mscertified said:
I have 2 combo boxes the second is dependent on the first. When the first
is
clicked, I requery the second in the OnClick event. When the requeried
combo
box has only one row, I'd like this to be auto selected. How can I do
this?
Thanks.

With Me.ComboboxName
If .ListCount = 1 Then
.Value = .ItemData(0)
End If
End With
 
I have 2 combo boxes the second is dependent on the first. When the first is
clicked, I requery the second in the OnClick event. When the requeried combo
box has only one row, I'd like this to be auto selected. How can I do this?
Thanks.

Run this after the requery:

If Me.Combo0.ListCount = 1 Then Me.Combo0 = Me.Combo0.Column(0, 0)

.... and it will select the value.
 

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

Similar Threads

Requery combo box in subform 5
list box requery 1
Cannot requery 4
Combo Box Help 5
Combo Box Choose Record Problem 4
Cascading Combos Again 1
2 combo boxes 2
Testing for required data entry in form fields. 6

Back
Top