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. populating a datacombo based on what was chosen from another

populating a datacombo based on what was chosen from another

Scheduled Pinned Locked Moved Visual Basic
question
4 Posts 2 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.
  • M Offline
    M Offline
    mcm
    wrote on last edited by
    #1

    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!

    K 1 Reply Last reply
    0
    • M mcm

      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!

      K Offline
      K Offline
      Keder
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • K 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

        M Offline
        M Offline
        mcm
        wrote on last edited by
        #3

        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??!!

        K 1 Reply Last reply
        0
        • M mcm

          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??!!

          K Offline
          K Offline
          Keder
          wrote on last edited by
          #4

          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

          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