|
Question : How to connect two combo boxes
|
|
Hi Experts, I researched on how to connect two combo boxes here, but I am missing something probably very basic.
So I have a form, which is named VBA_Queries, at least this shows up when I am looking at the available forms.
I also have the two combo boxes. First one is named gelsCombo. and the second one is named spotsCombo
In the first one I use a query, giving all the gels from the table. SELECT GelName FROM Gels In the after update event I put spotsCombo.requery.
The problem starts here. Access complains about not finding the macro spotsCombo. I also tried me.spotsCombo which then resulted in missing makro me.
Any ideas?
|
|
Answer : How to connect two combo boxes
|
|
>Still the same error: Check the spelling of your combo box name to make sure it's spelled correctly. Easiest way to do this is in your code type Me. and let the intelli-sense window popup, then scroll down to spotsCombo.
Once you get this working, you'll need code like this..
Private Sub gelsCombo_AfterUpdate() Me.spotsCombo.RowSource = "SELECT SpotID, Name FROM Spots WHERE SomeFieldInSpots = Me.gelsCombo" End Sub
(1) Rename SomeFieldInSpots to whatever field in table Spots you want to compare this with. (2) If the field is Text, you'll need to surround it with single quote marks "... WHERE SomeFieldInSpots = '" & Me.gelsCombo & "'"
|
|
|
|