How do I loop through the values in a combocox?

dogdays

Active Member
Joined
Apr 28, 2008
Messages
431
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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

jackd

Well-known Member
Joined
Oct 19, 2006
Messages
1,396
Office Version
  1. 365
What are you trying to do? Forget Access for the moment, just in plain english tell us the issue. Maybe there are other approaches.
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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...
 

dogdays

Active Member
Joined
Apr 28, 2008
Messages
431
I was trying to validate data in an existing table. Accomplished in a different way. Thanks for the comments.

Jack
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,652
Messages
5,854,960
Members
431,689
Latest member
jacker01

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
Top