A little puzzle with passing ID and displayed fields from form to another in combo box i VB2003

I have a combo box populated by OleDbDataAdapter in a form. And I have to pass the selected value to other forms for display. But I also want to pass the ID field (which is integer) so that I can sae the ID of the selected item rather than the text itself.


I use a OleDbDataAdapter in, oledbconnection and data set in my forms. I also use Display member to display the right column (text in my case) and and Value member to associate my item to the ID field which is integer.
My problem I can pass either the ID field or the selected text field but I don t know ho to pass both

Thanks a lot. I apreciate your help.




Answer this question

A little puzzle with passing ID and displayed fields from form to another in combo box i VB2003

  • Katee

    you are right it should be just text

     

    eg:  mycombo.text

    remco


  • Justin Lee

    Thanks a lot, That works perfectly. u re really cool.

    Tell me, do we have any other way to pass both ID and text value to the other forms besides passing both params. It ll take much resources to pass both ID and text each time.

    Is there a way to pass just one value (ID for example) and at the same being able to get the other field (selected text for example) for display in the other forms. The ID field will be used for saving ID field in the table and for future retrieval purposes.

     

    Grcaias



  • Jaime Stuardo

    tutus,

    Selectedtext gives  displaymember

    Selectedvalue gives  valuemember

    there are several ways to do this, one way is making a function in the calling form that accept 2 parameters 1 for the valuemember and 1 for the displaymember

    Remco


  • Darko01

    Hi Remco,

    Selectedvalue gives  me valuemember which is my ID field, however

    selectedtext gives me nothing (empty value)

    may be i m doing something wrong. I guess all I need in my combobox bimdings is to set the properties: DisplayMember and Value Member and of course the Datasource to the dataset

    I get selectedText empty

     

    Thanks



  • A little puzzle with passing ID and displayed fields from form to another in combo box i VB2003