revver
Active Member
- Joined
- Dec 20, 2007
- Messages
- 257
I have 2 tables with 1-many relationship. I need to be able to duplicate a record in the parent table and all its children.
So far I have a snippet thus
All very good in theory but DLookup fails. It returns the first ever record in the Parent. What can I do to determine with certainty the NewParentID?
So far I have a snippet thus
VBA Code:
BeginTrans
' First Copy the Parent Record (from [rsS]) and then the Child records one by one
With rst
.AddNew
.CatNum = rsS.CatNum ... and other fields
.Notes = rsS.Notes & "Copied from " & txtSource
.Update
** NewParentID = DLookup("ParentID", "ParentTable", "CatNum = '" & txtTarget & "'"
End With
'Create Recordset of Children to copy to new parent ...
'Create New Children with NewParentID