fill combo box with table items
-
this is whaT I have....
Dim i As Integer Do While Not rs.EOF For i = 0 To rs.Fields.Count - 1 DepartmentCbo.Text = DepartmentCbo.Text & rs.Fields("Department").Value LocationCbo.Text = LocationCbo.Text & rs.Fields("Location").Value Next rs.MoveNext() Loop
What am i missing??? the result is the contents are filled next to one another not listed like this museumplanetariumfloor1floor2 it should b like this museum planetarium floor 1 floor2 etc. Help is great only if you ask correctly -
this is whaT I have....
Dim i As Integer Do While Not rs.EOF For i = 0 To rs.Fields.Count - 1 DepartmentCbo.Text = DepartmentCbo.Text & rs.Fields("Department").Value LocationCbo.Text = LocationCbo.Text & rs.Fields("Location").Value Next rs.MoveNext() Loop
What am i missing??? the result is the contents are filled next to one another not listed like this museumplanetariumfloor1floor2 it should b like this museum planetarium floor 1 floor2 etc. Help is great only if you ask correctly -
hey, jlawren7: Did you re-type this to post it? Cause I'm seeing a very small bug... at the 'Next' line... shouldn't it say Next i? Regards. Pablo.
i copied and pasted the code i trid putting " i " after next but i still get the same results in vb6 i could do this ADODeptLocation.Refresh ADODeptLocation.Recordset.MoveFirst CboDepartment.AddItem ADODeptLocation.Recordset("Department") CboLocation.AddItem ADODeptLocation.Recordset("Location") 'loop through for all the records Do While Not ADODeptLocation.Recordset.EOF CboDepartment.AddItem ADODeptLocation.Recordset("Department") CboLocation.AddItem ADODeptLocation.Recordset("Location") ADODeptLocation.Recordset.MoveNext Loop CboDepartment.ListIndex = 0 CboLocation.ListIndex = 0 and this would fill the combo box list items Help is great only if you ask correctly :)
-
i copied and pasted the code i trid putting " i " after next but i still get the same results in vb6 i could do this ADODeptLocation.Refresh ADODeptLocation.Recordset.MoveFirst CboDepartment.AddItem ADODeptLocation.Recordset("Department") CboLocation.AddItem ADODeptLocation.Recordset("Location") 'loop through for all the records Do While Not ADODeptLocation.Recordset.EOF CboDepartment.AddItem ADODeptLocation.Recordset("Department") CboLocation.AddItem ADODeptLocation.Recordset("Location") ADODeptLocation.Recordset.MoveNext Loop CboDepartment.ListIndex = 0 CboLocation.ListIndex = 0 and this would fill the combo box list items Help is great only if you ask correctly :)
If you are usinig VB .NET you could easily just set the combobox datasource to the dataset you are going to use for it and then set the displaymember property to the field in the dataset in the properties box of the combobox.