How do I loop through the values in a combocox?

dogdays

Active Member
Joined
Apr 28, 2008
Messages
434
Office Version
  1. 2007
I have a combobox with three columns of data, I wish to loop through each row to find a particular value in the first column. I tried the following:
Rich (BB code):
Private Sub Form_Current()
    Dim iIndex As Integer
    
    For iIndex = 0 To Me.cboRelationshipTypes.ListCount - 1
        If Me.cboRelationshipTypes(iIndex).Column(0) = 7 Then
            Me.cboRelationshipTypes.ListIndex = iIndex
            Exit Sub
        End If
    Next iIndex
End Sub

The line in blue gives me a Type Mismatch error. Any help would be appreciated.

Jack
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
What are you trying to do? Forget Access for the moment, just in plain english tell us the issue. Maybe there are other approaches.
 
Upvote 0
Seems like you can just use the value:

Me.ComboBox1.Value = 7

Then you're on that row.

As above --> what's the ultimate aim...
 
Upvote 0
I was trying to validate data in an existing table. Accomplished in a different way. Thanks for the comments.

Jack
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,696
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top