G
Guest
I am using DAO coding to create new records in a table that already exists.
I am presently creating the records in the order they exist in another table
by reading the second table sequentially. This creates the new table in
random order the same as the second table. The new table is emptied before
the process. If I were to do this process in SQL I could use an ‘oder by’
clause that would put the new records in a particular order. Is there a
procedure for accomplishing the same thing in the DAO coding? I have listed
the code that I am using below:
Dim db1 As DAO.Database
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set db1 = CurrentDb()
Set rst1 = db1.OpenRecordset("SecondTable", dbOpenDynaset)
Set rst2 = db1.OpenRecordset("NewTable", dbOpenDynaset)
rst1.MoveFirst
op1:
If rst1.EOF Then GoTo opclose
rst2.AddNew
various code statements defining strings
rst2.Update
rst1.MoveNext
GoTo op1
opclose:
rst1.Close
rst2.Close
db1.Close
Thank you for any assistance.
I am presently creating the records in the order they exist in another table
by reading the second table sequentially. This creates the new table in
random order the same as the second table. The new table is emptied before
the process. If I were to do this process in SQL I could use an ‘oder by’
clause that would put the new records in a particular order. Is there a
procedure for accomplishing the same thing in the DAO coding? I have listed
the code that I am using below:
Dim db1 As DAO.Database
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set db1 = CurrentDb()
Set rst1 = db1.OpenRecordset("SecondTable", dbOpenDynaset)
Set rst2 = db1.OpenRecordset("NewTable", dbOpenDynaset)
rst1.MoveFirst
op1:
If rst1.EOF Then GoTo opclose
rst2.AddNew
various code statements defining strings
rst2.Update
rst1.MoveNext
GoTo op1
opclose:
rst1.Close
rst2.Close
db1.Close
Thank you for any assistance.