I am having two problems with my recordset. Firstly, when I try to execute the code it tells me "Operation not allowed when this object is open" hilighting my Open command. Secondly, this is to create a new record in the table, but I don't know how to tell it to move to a new record. Will it do so automatically?
TIA!
Minkers
TIA!
Minkers
Code:
Dim rs As New ADODB.Recordset
Dim varECNID As Integer
Dim varItem As Variant, strSQL As String, i As Integer
i = 0
For Each varItem In Me.lstModels.ItemsSelected
varECNID = Me.ECNID
strSQL = "SELECT tblCost.ECNID, tblCost.Quantity, tblCost.Phase, tblCost.Workstation, tblCost.UnitCost, tblCost.PartID, tblCost.ModelID, tblCost.StandardOrOptionalID, tblCost.PartAddDel" _
& " FROM tblCost;"
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rs.Fields("ECNID").Value = Me.ECNID
rs.Fields("Quantity").Value = Me.Quantity
rs.Fields("Phase").Value = Me.Phase
rs.Fields("Workstation").Value = Me.Workstation
rs.Fields("UnitCost").Value = Me.UnitCost
rs.Fields("PartID").Value = Me.PartID
rs.Fields("ModelID").Value = varItem
rs.Fields("StandardOrOptionalID").Value = Me.StandardOrOptional
rs.Fields("PartAddDel").Value = Me.PartAddDel
rs.Update
i = i + 1
Next varItem
If i > 0 Then
MsgBox i & " Models were updated", , "Done"
Else
MsgBox "No models were chosen", , "No changes"
End If
rs.Close
Set rs = Nothing
End Sub