Userform Combobox - Link to Index of Unbound Column?

ClimoC

Well-known Member
Joined
Aug 21, 2009
Messages
584
Ello

I have a disconnected ADODB, which userforms access. To search for items to perform actions on, there are 2 comboboxes. The first is my custom 'UniqueID' string ("AAAAA, AAAAB, etc"). The second is has two columns, the first is the Unique ID again, the second (which is ALSO THE BOUND COLUMN), is the Name of the entry in the dataset.

What I'm trying to do, is allow people to select/type the Unique ID (if they know it), but also be able to type/select by the Name.

I had it at the point where you type/select the UniqueID from CB1, and it picks AN entry from CB2 with a similar name (match an item from the bound column with the field value 'Name' from the UID), but anything with a duplicate name caused it to grab anything that matched that name.

So the tricky thing I need to do - and I don't know if I even can, is this:

1) Pick the UID from CB1, and it grabs the CORRECT entry from CB2 based on the CB2.Column(0)

2) be able to use CB2 to bring up Text-matching entries from Bound Column 2

Any ideas?

So far, I have:

Code:
Private Sub Combobox1_Change()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

OFFLDb.MoveFirst
OFFLDb.Find = "UniqueID = '" & ComboBox1.Value & "'"
If Not OFFLDb.EOF = True And Not OFFLDb.BOF = True Then
With OFFLDb
        Me.ComboBox2.Column(0) = .Fields("UniqueID").Value
        

End With
End If
End Sub
...And that doesn't work.... "Runtime 381 - Could not set the Columm property. Invalid property array Index."

And the other...

Code:
Private Sub Combobox1_Change()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

OFFLDb.MoveFirst
OFFLDb.Find = "UniqueID = '" & ComboBox1.Value & "'"
If Not OFFLDb.EOF = True And Not OFFLDb.BOF = True Then
With OFFLDb
        Me.ComboBox2.Column(1) = .Fields("Name").Value
        

End With
End If
End Sub
Grabs the first entry it finds with a matching name. (So if 3 records with their own UID's have the same name, and you pick the second or third one by Name, the first UID is selected!)

Any comments/suggestions welcome

Cheers
C
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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