Solved

ComboBox Selectvalue return nothing.

Posted on 2009-04-01
5
151 Views
Last Modified: 2012-06-27
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
Comment
Question by:siacom
5 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24047369
Is your StaffID a numeric value or a string ?
Did you check the selectedText, selectedIndex, selectedValue, ... ? (to make sure that something is selected)
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24049189
Try changing this line
Me.ipCbCSO.Text = txtCSOname.Text

to this
Me.ipCbCSO.SelectedIndex = ipCbCSO.FindStringExact(txtCSOname.Text)
0
 

Author Comment

by:siacom
ID: 24154107
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24155482
>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
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24166058

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

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question