Auto-select combo box entry when only one row

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.
 
S

Stuart McCall

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
 
M

Minton M

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

Top