• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

ComboBox Selectvalue return nothing.

I am trying to read and set the value of an item in a combo box.
when flicking through the dataset the SelectedValue is always nothing

However the text returns the current value.

I want to set and retrieve the SelectedValue (StaffID), how can I do that ?



OnLoad init combo box:
       ' No problem there the list comes up perfectly
        With Me.ipCbCSO
            .DataSource = Me.bsStaffList
            .ValueMember = "staffID"
            .DisplayMember = "name"
        End With
 
 
....   ON databound positionchanged:
        ' Set Combo text value. (Since I cannot SET the ID value ??)
        Me.ipCbCSO.Text = txtCSOname.Text
         ' This works fine.
        Debug.Print("******** >>>>" & Me.ipCbCSO.Text)
          ' Returns nothing
        Debug.Print("******** ======>>>>" & ipCbCSO.SelectedValue)

Open in new window

0
siacom
Asked:
siacom
1 Solution
 
DhaestCommented:
Is your StaffID a numeric value or a string ?
Did you check the selectedText, selectedIndex, selectedValue, ... ? (to make sure that something is selected)
0
 
CodeCruiserCommented:
Try changing this line
Me.ipCbCSO.Text = txtCSOname.Text

to this
Me.ipCbCSO.SelectedIndex = ipCbCSO.FindStringExact(txtCSOname.Text)
0
 
siacomAuthor Commented:
Sorry for any late replies.. I was on holidays :)

staffid is integer.
I removed any values in selected index because it just doesn't give the appropriate result.
0
 
CodeCruiserCommented:
>I removed any values in selected index because it just doesn't give the appropriate result.
What do you mean? Did you try using the code?
0
 
JackOfPHCommented:

 Debug.Print("******** ======>>>>" & ipCbCSO.items.item(ipCbCSO.SelectedIndex).value)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now