This is my first post and may be a doosie (but I certainly hope NOT):I am using the following code to duplicate records in the front end of an Access database with tables on SQL Server 2005:Private Sub DuplicateRecord_Click()On Error GoTo Err_Handler Dim intQty As Integer Dim intNewQty As Integer Dim strPartNo As String Dim strMsg As String Dim Response Dim intCount As Integer Dim rs As DAO.Recordset Dim db As DAO.Database Set rs = Me.RecordsetClone Set db = CurrentDb() 'Make sure there is a record to duplicate If Me.NewRecord Then strMsg = "Select the record to duplicate." MsgBox strMsg, 0, "PARTS Database Message" Else 'Capture the Qty and PartNo values intQty = Me.Qty.Value strPartNo = Me.PartNo.Value If intQty < 2 Then strMsg = "The quantity has to be greater than 1" _ & Chr(13) & "before you can duplicate a record." _ & Chr(13) & Chr(13) & "Increase the Qty in the form and" _ & Chr(13) & "then try again." MsgBox strMsg, 0, "PARTS Database Message" ElseIf intQty = 2 Then Me.Qty.Value = 1 intNewQty = 1 intCount = intQty - 1 ElseIf intQty > 2 Then strMsg = "If you want to create " & intQty - 1 & " duplicates for a total of " & intQty & " records, click 'Yes'." _ & Chr(13) & "Otherwise click 'No' to create 1 duplicate with the same Qty of " & intQty & "." Response = MsgBox(strMsg, 3, "Create Multiple Duplicates (Y/N)?") If Response = vbNo Then intNewQty = Me.Qty.Value intCount = 1 ElseIf Response = vbYes Then Me.Qty.Value = 1 intNewQty = 1 intCount = intQty - 1 End If End If End If If intCount > 0 Then 'Clear the Received check so record isn't discarded in the requery below If Me.Received_Tag = True Then Me.Received_Tag = False Me.Received_TagCheck = Null End If 'Save any edits before running SQL If Me.Dirty Then Me.Dirty = False Do While intCount > 0 'Duplicate the record: add to form's clone With Me.RecordsetClone .AddNew '<<<<<<<<Invalid operation [3219] !ProjectTitle = Me.ProjectTitle.Value '<<<<<<<<Field cannot be updated [3164] - occurs on all subsequent fields !Site = Me.Site.Value !ReqID = Me.ReqID.Value !PartNo = Me.PartNo.Value !Qty = intNewQty !Price = Me.Price.Value !AssetNotes = Me.AssetNotes.Value .Update If Me.Dirty Then Me.Dirty = False intCount = intCount - 1 End With Loop DoCmd.Requery Me.Recordset.FindFirst "[PartNo] = " & "'" & strPartNo & "'" End If rs.Close Set rs = Nothing Set db = Nothing Exit_Here: Exit SubErr_Handler: MsgBox Err.Description & " [" & Err.Number & "]" Resume Exit_HereEnd Sub
At some point in the past, this code worked beautifully for me and it still works with local tables in Access. Evidently some change has occurred in my table structure that is causing this error.I currently have no Diagrams or restraints, aside from table PKs and SKs, defined in the database to help zero-in on the problem with no luck so far.The record I am attempting to duplicate is populated by the following query:SELECT dbo_tblAssets.ReqID, dbo_tblAssets.ProjectTitle, dbo_tblRequisition.Vendor, dbo_tblMateriel.Manufacturer, dbo_tblAssets.PartNo, dbo_tblAssets.AssetID, dbo_tblAssets.Site, dbo_tblRequisition.JON, dbo_tblRequisition.Requestor, dbo_tblMateriel.ParentPN, dbo_tblMateriel.PartName, dbo_tblMateriel.MaterielType, dbo_tblMateriel.PhotoLink, dbo_tblMateriel.AffixIUIDLink, dbo_tblRequisition.ReqType, dbo_tblRequisition.Buyer, dbo_tblRequisition.InvoiceLink, dbo_tblRequisition.ReqDate, dbo_tblRequisition.GroupNo, dbo_tblRequisition.ReqNo, dbo_tblRequisition.DocNo, dbo_tblRequisition.PONo, dbo_tblRequisition.VendorPN, dbo_tblRequisition.QtyOrdered, dbo_tblAssets.Price, dbo_tblAssets.Qty, dbo_tblAssets.QtyUsed, [Qty]-[QtyUsed] AS QtyLeft, dbo_tblRequisition.Courier, dbo_tblCourier.CourierURL, dbo_tblRequisition.TrackNo, dbo_tblRequisition.ShipDate, dbo_tblRequisition.ReqOrdered_Tag, dbo_tblAssets.Received_Tag, dbo_tblAssets.SerNo, dbo_tblAssets.PartIUID, dbo_tblAssets.BoxLabel_Tag, dbo_tblMovement.MoveID, dbo_tblMovement.MoveDate, dbo_tblMovement.Organization, dbo_tblMovement.Location, dbo_tblMovement.SubLocation, dbo_tblMovement.BoxNo, dbo_tblMovement.Custodian, dbo_tblMovement.MoveBy, dbo_tblRequisition.PackSlipLink, dbo_tblRequisition.InspectLink, dbo_tblAssets.AssetNotes, dbo_tblRequisition.ReqNotesFROM dbo_tblCourier RIGHT JOIN (dbo_tblRequisition RIGHT JOIN (dbo_tblMateriel RIGHT JOIN (dbo_tblAssets LEFT JOIN dbo_tblMovement ON dbo_tblAssets.AssetID = dbo_tblMovement.AssetID) ON dbo_tblMateriel.PartNo = dbo_tblAssets.PartNo) ON dbo_tblRequisition.ReqID = dbo_tblAssets.ReqID) ON dbo_tblCourier.Courier = dbo_tblRequisition.CourierWHERE (((dbo_tblRequisition.ReqOrdered_Tag)=Yes) AND ((dbo_tblAssets.Received_Tag)=No) AND ((dbo_tblRequisition.ReqNotes) Is Null)) OR (((dbo_tblRequisition.ReqOrdered_Tag)=Yes) AND ((dbo_tblAssets.Received_Tag)=No) AND ((dbo_tblRequisition.ReqNotes) Not Like "*" & "Prior Requisition" & "*"))ORDER BY dbo_tblRequisition.Vendor, dbo_tblMateriel.Manufacturer, dbo_tblAssets.PartNo, dbo_tblAssets.AssetID;
Does anyone have any ideas where I should look to eliminate the cause of this problem. It shouldn't be the coding (VBA or Query) since it worked in the past. I'm pretty sure it has to do with some property within the SQL server and I'm a newbie working with SQL Server.Thanks for any suggestions you may be able to provide!!!