CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Posts
    20

    Can anyone answer this?

    I have a dropdown data combo box that lists a project number. I want to be able to select a project number in the combo box then assign it to a global variable. The project number, lets say 8815, should then be stored in the global variable gloCurrProjNum. I've written the code but i keep getting the list number (1) instead of the actual project number (8815). Heres the code:

    Private Sub DataCombo1_Click(Area As Integer)
    If Area = dbcAreaList Then
    glocurrProjNum = DataCombo1.SelectedItem
    End If
    End Sub

    Can anyone see what i'm doing wrong?



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Can anyone answer this?

    Try this
    Private Sub Combo1_Click()
    glocurrProjNum = Combo1.Text
    End Sub


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 2001
    Posts
    20

    Re: Can anyone answer this?

    Thanks Iouri. Your post plus David's helped me solve this problem.


  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    I can

    The selecteditem property doesn't return the value, but it returns a bookmark from the recordset which is in the rowsource property (most likely a datacontrol or a recordset).
    You can get the value this way:

    private Sub DataCombo1_Click(Area as Integer)

    If Area = dbcAreaList then
    dim bm as variant
    bm = DataCombo1.SelectedItem
    ' assuming that the rowsource is named data1
    ' and the inputcolumn is projectnumber
    data1.recordset.bookmark = bm
    glocurrProjNum = data1.recordset.fields("projectnumber")
    End If

    End Sub






    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured