populating a datacombo based on what was chosen from another
-
i am trying to populate a datacombo box based on what has been chosen from another using the following code: Dim RS As ADODB.Recordset Set RS = New ADODB.Recordset Dim strProductType As String strProductType = DataComboType.Text Dim descSQL As String descSQL = "SELECT Product.Description FROM ProductType INNER JOIN Product ON ProductType.TypeCode = Product.TypeCode WHERE ProductType.Description= '" & strProductType & "'" Set RS = Conn.Execute(descSQL) Do While Not RS.EOF DataComboProduct.DataField = RS.Fields("Description") RS.MoveNext Loop However, the second combo box does not populate at all - why is this? Thank you!
-
i am trying to populate a datacombo box based on what has been chosen from another using the following code: Dim RS As ADODB.Recordset Set RS = New ADODB.Recordset Dim strProductType As String strProductType = DataComboType.Text Dim descSQL As String descSQL = "SELECT Product.Description FROM ProductType INNER JOIN Product ON ProductType.TypeCode = Product.TypeCode WHERE ProductType.Description= '" & strProductType & "'" Set RS = Conn.Execute(descSQL) Do While Not RS.EOF DataComboProduct.DataField = RS.Fields("Description") RS.MoveNext Loop However, the second combo box does not populate at all - why is this? Thank you!
Hi I assume that "DataComboProduct" is the name of your second combobox, and that you are sure that you recieve records to your recordset. I have not used the "DataField" method so I don't know how it works. My suggestion is: DataComboProduct.AddItem RS.Fields("Description") Good luck //Keder
-
Hi I assume that "DataComboProduct" is the name of your second combobox, and that you are sure that you recieve records to your recordset. I have not used the "DataField" method so I don't know how it works. My suggestion is: DataComboProduct.AddItem RS.Fields("Description") Good luck //Keder
-
Thank you so much for your help - i tried the AddItem method (which does make sense) but it returned the error "Method or data item not found"....is there anything else i could try??!!
I'm not sure but I think the error message says that it couldn't find RS.Fields("Description"). When you write your select statement you use Product.Description, maybe that have something to do with it. Try this, not so nice, but it works RS.Fields(0) 'Description If you had recieved more info you should write RS.Fields(1) 'Name RS.Fields(2) 'Street //Keder