Hi! I'm having issues setting values for when the child records copy over. I tried the following code on the lesson download database and setting the values (= Null or = "") doesn't work beginning at line 290. Please advise
' copy the order details 200 Set rsOld = CurrentDb.OpenRecordset("SELECT * FROM OrderDetailT WHERE OrderID=" & OrderID) 210 Set rsNew = CurrentDb.OpenRecordset("OrderDetailT") 220 While Not rsOld.EOF 230 rsNew.AddNew 240 For Each Fld In rsOld.Fields 250 If Fld.Name = "OrderID" Then 260 rsNew!OrderID = NewID 270 ElseIf Fld.Name <> "OrderDetailID" Then 280 rsNew(Fld.Name) = rsOld(Fld.Name) 290 ElseIf Fld.Name = "ProductName" Then 300 rsNew!ProductName = "" ElseIf Fld.Name = "UnitPrice" Then rsNew!UnitPrice = Null 310 End If 320 Next 330 rsNew.Update 340 rsOld.MoveNext 350 Wend 360 rsNew.Close 370 rsOld.Close 380 Set rsNew = Nothing 390 Set rsOld = Nothing
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.