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.
 
Back
Top