PDA

Click to See Complete Forum and Search --> : ComboBox Help


teddie
Aug 3rd, 1999, 12:54 AM
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.

Serge
Aug 3rd, 1999, 03:13 PM
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com




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