dmmckelv
12-11-2008, 03:33 AM
Hello,
I used VBA to create a table based on the data in a query. The SQL statement includes ORDER BY Start Time. The VBA is similiar to:
[code]
Dim db As DAO.Database
Dim work as TableDef
Dim all the fields As Fields
Set db =Currentdb
Set work = db.CreateTableDef("workTable")
Set "all the fields" = work.CreateField("blah", db"")
Append All the fields
Append the db
Set Work = db.OpenRecordset("workTable", dbOpenDynaSet)
Set WorkQuery = db.OpenRecordset("workQuery", dbOpenDynaSet)
If Not WorkQuery.EOF Then
WorkQuery.MoveFirst
End If
Do While Not WorkQuery.EOF
Work.AddNew
Work("blah").Value = WorkQuery!blah
etc for all the fiels
WorkQuery.MoveNext
Loop [/ code]
When I open the table, it is in a completely different order. Any ideas why? Is there a way to quickly re-order the table using VBA or even better to prevent this from happening.
Thanks for your help!
Mark
I used VBA to create a table based on the data in a query. The SQL statement includes ORDER BY Start Time. The VBA is similiar to:
[code]
Dim db As DAO.Database
Dim work as TableDef
Dim all the fields As Fields
Set db =Currentdb
Set work = db.CreateTableDef("workTable")
Set "all the fields" = work.CreateField("blah", db"")
Append All the fields
Append the db
Set Work = db.OpenRecordset("workTable", dbOpenDynaSet)
Set WorkQuery = db.OpenRecordset("workQuery", dbOpenDynaSet)
If Not WorkQuery.EOF Then
WorkQuery.MoveFirst
End If
Do While Not WorkQuery.EOF
Work.AddNew
Work("blah").Value = WorkQuery!blah
etc for all the fiels
WorkQuery.MoveNext
Loop [/ code]
When I open the table, it is in a completely different order. Any ideas why? Is there a way to quickly re-order the table using VBA or even better to prevent this from happening.
Thanks for your help!
Mark