M
mattc66 via AccessMonster.com
Below is my code that I am having trouble with. Both Tables have a related
fld called CustomerPO. What I need is RS1 to grab the first record and then
get the related RS2 records before it goes and gets the next PO.
Can someone read my code and help me write in order to do this.
Thanks
CODE>>>>>>>>>>>>>>>>>>>>>
Function copyOrder()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim rs5 As DAO.Recordset
Dim varReturn As Variant
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("850_OrderRecord")
Set rs2 = db.OpenRecordset("850_DetailRecord")
Set rs5 = db.OpenRecordset("EDI_850_Export")
rs1.MoveFirst
While Not rs1.EOF
With rs5
rs5.AddNew
rs5.Fields("R_TYPE") = rs1.Fields("R_TYPE")
rs5.Fields("FLD1") = Nz(rs1.Fields("CUSTOMER_ID"), "") ' helps to
deal with nulls in bundle table
rs5.Fields("FLD2") = Nz(rs1.Fields("CUSTOMER_PO"), "") ' it says
if there's a null, use this
rs5.Fields("FLD3") = Nz(rs1.Fields("ORDER_DATE"), "") '<--in this
case, a blank
rs5.Update
End With
rs1.MoveNext
Wend
Set rs1 = Nothing
rs2.MoveFirst
While Not rs2.EOF
With rs5
rs5.AddNew
rs5.Fields("R_TYPE") = Nz(rs1.Fields("R_TYPE"), "")
rs5.Fields("FLD1") = Nz(rs1.Fields("CUSTOMER_ID"), "") ' helps to
deal with nulls in bundle table
rs5.Fields("FLD2") = Nz(rs1.Fields("CUSTOMER_PO"), "") ' it says
if there's a null, use this
rs5.Fields("FLD3") = Nz(rs1.Fields("ITEM"), "") '<--in this case,
a blank
rs5.Update
End With
rs2.MoveNext
Wend
Set rs1 = Nothing
Set rs2 = Nothing
Set rs5 = Nothing
End Function
fld called CustomerPO. What I need is RS1 to grab the first record and then
get the related RS2 records before it goes and gets the next PO.
Can someone read my code and help me write in order to do this.
Thanks
CODE>>>>>>>>>>>>>>>>>>>>>
Function copyOrder()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim rs5 As DAO.Recordset
Dim varReturn As Variant
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("850_OrderRecord")
Set rs2 = db.OpenRecordset("850_DetailRecord")
Set rs5 = db.OpenRecordset("EDI_850_Export")
rs1.MoveFirst
While Not rs1.EOF
With rs5
rs5.AddNew
rs5.Fields("R_TYPE") = rs1.Fields("R_TYPE")
rs5.Fields("FLD1") = Nz(rs1.Fields("CUSTOMER_ID"), "") ' helps to
deal with nulls in bundle table
rs5.Fields("FLD2") = Nz(rs1.Fields("CUSTOMER_PO"), "") ' it says
if there's a null, use this
rs5.Fields("FLD3") = Nz(rs1.Fields("ORDER_DATE"), "") '<--in this
case, a blank
rs5.Update
End With
rs1.MoveNext
Wend
Set rs1 = Nothing
rs2.MoveFirst
While Not rs2.EOF
With rs5
rs5.AddNew
rs5.Fields("R_TYPE") = Nz(rs1.Fields("R_TYPE"), "")
rs5.Fields("FLD1") = Nz(rs1.Fields("CUSTOMER_ID"), "") ' helps to
deal with nulls in bundle table
rs5.Fields("FLD2") = Nz(rs1.Fields("CUSTOMER_PO"), "") ' it says
if there's a null, use this
rs5.Fields("FLD3") = Nz(rs1.Fields("ITEM"), "") '<--in this case,
a blank
rs5.Update
End With
rs2.MoveNext
Wend
Set rs1 = Nothing
Set rs2 = Nothing
Set rs5 = Nothing
End Function