Hi!
Here's a procedure that works fine between two forms, a master and a
detail.
Why not just try and add a second sql string and see if u can update
the second subform. Haven't tried it my self
(Code worked out by Al Kallal)
Me.Name
Private Sub cmdCopy_Click()
On Error GoTo Err_Copy
Dim rs As DAO.Recordset
Dim sqlNew As String
Dim lngNewOrderID as Long
'Force a diskwrite of current record
Me.Refresh
Set rs = Me.RecordsetClo ne
With rs
..AddNew
!CustID = Me!CustID
!EmployeeID = Me!EmployeeID
!CarID = Me!CarID
..Update
End With
'Now get ID of this new order just added.
'Simply move to last record changed
rs.Bookmark = rs.LastModified
lngNewOrderID = rs!OrderID
'Now copy details to NEW OrderID
sqlNew = "INSERT INTO
tblOrderDetail( ItemID,Price,Am ount,Period,Art ,Anl,OrderID) " & _
"SELECT ItemID,Price,Am ount,Period,Art ,Anl," & lngNewOrderID & _
'Please notice: NO SPACE AFTER LAST FIELD but
'SPACE BEFORE NEXT FIELD
" FROM tblOrderDetails " & _
"WHERE OrderID = " & Me!OrderID
CurrentDb.Execu te sqlNew, dbFailOnError
Wout skrev:
Hello there,
i have a main form to define products in.
i have a subform1 to fill in the related materials
i have a subform2 to fill in the machines to process the materials
subform1 is related to mainform through "ProductId" , subform2 is
related to subform1 through "MaterialId "
both subforms are displayed on the mainform.
i need to find out how i can copy a product-record including all
related records so i can make small adjustments in the "new" product
and save it as a new product.
i hope i made a bit clear what i mean ( my english/ jargon is not so
well)
any suggestions are welcome!!
thanks a lot in advance
Wout