Hi there,
In the process of testing a conversion from Access2007 to SQLServer2008 I am getting the following error –
“Error in Procedure AddEndorsement (3164) Field can’t be updated”
in the Front End from the stated procedure which adds a new transaction to a table based on previous data contained therein. When adding an Endorsement, the procedure copies the Master Policy Ref and a variety of other details pertinent to that risk and posts these along with an incremented sub policy ref field (i.e. C00782AOO/05) and the updated/additional premium amount. The table in question has an autonumbered ID field which increments when the new record is posted.
Below is an extract of code and the point where the error occurs. I realise what I have posted here may not be that descriptive or detailed and quite vague, so please advise any additional detail I should post here.
Thanks and regards,
Niven
Partial code extract from the offending procedure:-
[b] ' Add Policy Record. Dim cmd As New adodb.Command Dim old As New adodb.Recordset With cmd .ActiveConnection = CurrentProject.Connection .CommandText = strQuery .CommandType = adCmdTable .Parameters.Refresh .Parameters("[prmTSMRef]") = strTSMRef End With old.CursorType = adOpenStatic old.Open cmd If old.RecordCount 1 Then wrk.Rollback old.Close DoCmd.Hourglass False MsgBox "Unable to update transaction, as transaction record count for: " & strTSMRef & " is 1", vbExclamation Exit Sub End If ' Take a copy of the old Facility Ref strOrigFacRef = old("Facility Ref") ' We need the incept date for the attacment date, when it's open market. dteIncept = old("Incept") Set ins = db.OpenRecordset("tblPolicy", dbOpenDynaset, dbSeeChanges) Dim strtest As String ins.AddNew ' First copy orig record. Dim fld As adodb.Field For Each fld In old.Fields If fld.Name "id" Then ins.Fields(fld.Name).value = fld.value End If Debug.Print fld.Name; fld.value Next fld[/b] [img]http://windowssecrets.com/forums/images/smilies/excl.gif[/img] *****It gets to the the last field ok, but fails when when the loop finishes and tries to move to the next stage:- [b] ' Set any fields different than the originals record. ins("Facility Ref") = strFacRef ins("Written") = Now() ins("Original LPSO No") = Null ins("Original LPSO Date") = Null ins("Comments") = "" ins("Status") = "W" ins("Premium Due Date") = Null ins("Incept") = dteIncept ins("Created") = dteNow ins("Updated") = dteNow ins.Update ins.Close old.Close[/b]