Good Morning, this lesson has saved me a lot of headaches coming up with the best way to duplicate records and their children, but I am running into an issue. One of my table fields, TalkingPoint (similar to your Notes), won't copy the text over. I am trying to add (DUPLICATE) to the front, similar to your (COPY) but all it puts in the new record set is (DUPLICATE) - it seems to be ignoring the & rsOld!TalkingPoints portion... see code below:
DetailsSet rsOld = CurrentDb.OpenRecordset("SELECT * FROM tTalkingPoints WHERE idTalkingPoints=" & idTalkingPoints) Set rsNew = CurrentDb.OpenRecordset("tTalkingPoints") rsNew.AddNew NewID = rsNew!idTalkingPoints For Each Fld In rsOld.Fields If Fld.Name = "intendedDate" Then rsNew!intendedDate = Now ElseIf Fld.Name = "lastEditDate" Then rsNew!lastEditDate = Now ElseIf Fld.Name = "TalkingPoint" Then rsNew!TalkingPoint = "(DUPLICATED) " & rsOld!TalkingPoint ElseIf Fld.Name = "changeReason" Then rsNew!changeReason = "This talking point was duplicated from another taking point." ElseIf Fld.Name = "revisionX" Then rsNew!revisionX = 1 ElseIf Fld.Name = "revisionY" Then rsNew!revisionY = 0 ElseIf Fld.Name = "revisionZ" Then rsNew!revisionZ = 0 ElseIf Fld.Name = "finalApproved" Then rsNew!finalApproved = No ElseIf Fld.Name <> "idTalkingPoints" Then rsNew(Fld.Name) = rsOld(Fld.Name) End If Next
rsNew.Update rsNew.Close rsOld.Close
Jasen HicksOP
@Reply 2 years ago
If I remove the "(DUPLICATED) " it works as intended.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Developer 24.