?
Solved

ComboBox Selectvalue return nothing.

Posted on 2009-04-01
5
Medium Priority
?
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Independent Software Vendors: 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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

771 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