Solved

ComboBox Selectvalue return nothing.

Posted on 2009-04-01
5
152 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error message when using PrintSocket.Send 7 30
Vb.net threads keep increasing 2 50
MYSQL responding very slow 3 51
VB.Net creating Contact in Outlook 1 60
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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