Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. fill combo box with table items

fill combo box with table items

Scheduled Pinned Locked Moved Visual Basic
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jlawren7
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • J jlawren7

      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

      P Offline
      P Offline
      Pablo ar
      wrote on last edited by
      #2

      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.

      J 1 Reply Last reply
      0
      • P Pablo ar

        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.

        J Offline
        J Offline
        jlawren7
        wrote on last edited by
        #3

        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 :)

        C 1 Reply Last reply
        0
        • J jlawren7

          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 :)

          C Offline
          C Offline
          ccotton333
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups