Results 1 to 2 of 2

Thread: ComboBox Help

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Cookeville, Tn 38501
    Posts
    39

    Post

    Hi, I'm using this code to save a record from a combo box (via stored procedure where the field is a number):
    strTeamNo = cboTeamNo.Text
    strTeamNo = Left(strTeamNo, 2)
    qyPhoneLogInsert(4) = strTeamNo
    This will actually save the record. The problem occurs when I go to edit any of the records that were saved by this method. I get a Run-time error '380': Invalid property value on this code witch makes sure that the combo box's list index is already set to the record's current value:
    cboTeamNo.ListIndex = rsPhone!TEAM_NO - 1
    This code works in other instances. When I move the mouse over cboTeamNo.ListIndex it shows cboTeamNo.ListIndex = -1. When I move the mouse over rsPhone!TEAM_NO it shows rsPhone!TEAM_NO = 56. Another combo box that uses the ListIndex to save its records with identical code would show the 56 differently: '56'. Should I be formatting the record to be saved differently? If so, how?

    Here's the code for creating the combo box, someone my know of a better way to do this:
    strListTeamNo = " SELECT TEAM_NO, TEAM_NAME FROM TEAM_LOOK " & _
    " ORDER BY TEAM_NO"
    Set rsListTeamNo = gcOracleConnection.OpenResultset(strListTeamNo, _
    rdOpenForwardOnly, _
    rdConcurReadOnly)
    cboTeamNo.Clear
    While Not rsListTeamNo.EOF
    cboTeamNo.AddItem rsListTeamNo(0) & " " & rsListTeamNo(1)
    rsListTeamNo.MoveNext
    Wend
    Set rsListTeamNo = Nothing

    Note that the combo contains two fields. When the user selects an item from the combo, I just want to save the first field. In my db, that's a number field.


  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    If you're saying that TeamNO is a number, then why do you use strTeamNO. According the naming convention of that variable - it's a string data type.

    Try this:


    Dim lngTeamNO As Long

    lngTeamNO = Val(Left(cboTeamNo.Text, 2))


    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]




    [This message has been edited by Serge (edited 08-04-1999).]

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