synchronize two combo boxes on a form

K

KBDB

In the help section their is example code. I have tryed this and my
AfterUpdate event does not set my 2nd combo box's RowSourceType. All the
variables are showing the correct values. Would another property prevent my
RowSourceType from being updated?
 
T

Tom van Stiphout

On Tue, 8 Apr 2008 20:13:01 -0700, KBDB

Sorry, my crystal ball is in repairs. Could you kindly post the
relevant code?
-Tom.
 
K

KBDB

Private Sub 1stComboBoxName_AfterUpdate()
Me.2ndComboBoxName.RowSource = "SELECT whatYouWantField FROM" & _
" tblTableName WHERE 1stComboBoxFieldName = " & _
Me.1stCombBoxName

Me.2ndComboBoxName = Me.2ndComboBoxName.ItemData(0)
End Sub
 
K

KBDB

Sorry Wrote the Where clause wrong..
This one is right....

Private Sub 1stComboBoxName_AfterUpdate()
Me.2ndComboBoxName.RowSource = "SELECT whatYouWantField FROM" & _
" tblTableName WHERE TableFieldName = " & _
Me.1stCombBoxName

Me.2ndComboBoxName = Me.2ndComboBoxName.ItemData(0)
End Sub


:

this Where clause is wrong....
 
T

Tom van Stiphout

On Tue, 8 Apr 2008 20:58:00 -0700, KBDB

Thank you. Just like I thought you meant to say RowSource rather than
RowSourceType (which should be set to Table/Query).

Not sure what the purpose of this line is:
Me.2ndComboBoxName = Me.2ndComboBoxName.ItemData(0)
It would select the first item in the combobox. Is that the desired
effect?

Are your comboboxes standard, meaning an ID and Description field,
with the numeric ID field hidden? The BoundColumn set to 1,
ColumnCount=2, ColumnWidths="0;1"

-Tom.
 
K

KBDB

Yes, RowSourceType = Query/Table
Yes, numeric ID field hidden? The BoundColumn set to 1,
ColumnCount=2, ColumnWidths=0";1"

I would like the first row to be that which matches my Where Clause.

I went back and used the wizard and created the 2nd combo box with 2 fields,
1st field the key which is a number and 2nd field description - the one I
want to display.

Now I'm getting all the records in the 2nd combo box, seems my where clause
is not working.

MyTableFieldName was not selected during the wizard.

Any reason I would get all the records?


-Kathleen
 

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