I have a listbox that when using code to find out what the value is, it shows correctly the values selected. I have a code running on that lisbox that runs a recordset command. The value of the listbox in the code is always wrong. It seems to be random what value the number will be. The listbox has three columns, two hidden. The first columen is the ModelID, which is the number that is needed. It is also the bound column. Can anyone explain what might be the problem? Code Below.
Thanks in Advance!
Minkers.
Thanks in Advance!
Minkers.
Code:
Private Sub comSubmit_Click()
Set rs = New ADODB.Recordset
Dim varItem As Variant
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.ActiveConnection = CurrentProject.Connection
rs.Open "SELECT ECNID, Quantity, Phase, Workstation, " _
& "UnitCost, PartID, ModelID, StandardOrOptionalID, " _
& "PartAddDel " _
& "FROM tblCost;"
For Each varItem In Me.lstModels.ItemsSelected
varECNID = Me.ECNID
rs.AddNew
MsgBox varItem
rs!ECNID = ECNID
rs!Quantity = Quantity
rs!Phase = Phase
rs!Workstation = Workstation
rs!UnitCost = UnitCost
rs!PartID = PartID
rs!ModelID = varItem
rs!StandardOrOptionalID = StandardOrOptional
rs!PartAddDel = PartAddDel
Stop
rs.Update
i = i + 1
Next varItem
rs.Close
Set rs = Nothing
If i > 0 Then
MsgBox i & " Models were updated", , "Done"
Else
MsgBox "No models were chosen", , "No changes"
End If
End Sub