Hi all,
I am trying to copy record a record n times from one table to another where n is a value in that table.
The following code seems to work under Access97 but won't compile under Access2000. It objects to the DAO. in the Dim statements giving a "user-defined type not defined" message.
If I remove the DAO. from those statements, it will compile but I get a runtime error 13 - type mismatch error at the first set statement.
Can anyone please help?
As you experts can probably see, I'm new to this, so any advice would be welcome, including any better ways of achieving this.
Cheers,
Henio
Sub copyfile()
Dim i As Integer
Dim rec1 As DAO.Recordset
Dim rec2 As DAO.Recordset
Set rec1 = CurrentDb.OpenRecordset("Sheet1"
Set rec2 = CurrentDb.OpenRecordset("Sheet2"
Do While rec1.EOF = False
For i = 1 To rec1("Pallet Qty"
rec2.AddNew
rec2("Pallet Number"
= rec1("Pallet Number"
rec2("SKU"
= rec1("SKU"
rec2("EPM"
= rec1("EPM"
rec2("Qty"
= rec1("Qty"
rec2("Logical Day"
= rec1("Logical Day"
rec2("Quadrant"
= rec1("Quadrant"
rec2("Description"
= rec1("Description"
rec2("TUC"
= rec1("TUC"
rec2("Family Group"
= rec1("Family Group"
rec2("Pallet Qty"
= rec1("Pallet Qty"
rec2.Update
Next i
rec1.MoveNext
Loop
rec1.Close
rec2.Close
End Sub
I am trying to copy record a record n times from one table to another where n is a value in that table.
The following code seems to work under Access97 but won't compile under Access2000. It objects to the DAO. in the Dim statements giving a "user-defined type not defined" message.
If I remove the DAO. from those statements, it will compile but I get a runtime error 13 - type mismatch error at the first set statement.
Can anyone please help?
As you experts can probably see, I'm new to this, so any advice would be welcome, including any better ways of achieving this.
Cheers,
Henio
Sub copyfile()
Dim i As Integer
Dim rec1 As DAO.Recordset
Dim rec2 As DAO.Recordset
Set rec1 = CurrentDb.OpenRecordset("Sheet1"
Set rec2 = CurrentDb.OpenRecordset("Sheet2"
Do While rec1.EOF = False
For i = 1 To rec1("Pallet Qty"
rec2.AddNew
rec2("Pallet Number"
rec2("SKU"
rec2("EPM"
rec2("Qty"
rec2("Logical Day"
rec2("Quadrant"
rec2("Description"
rec2("TUC"
rec2("Family Group"
rec2("Pallet Qty"
rec2.Update
Next i
rec1.MoveNext
Loop
rec1.Close
rec2.Close
End Sub