M
MechEngr
Looking for a little help with deleting a table. I have six tables that I
have two versions of... one new and one old, ie. HQMembers & HQMembers_OLD.
In my procedure I wish to update the database by deleting the “_OLD†tables,
rename the Current Tables by appending the “_OLDâ€, and then import six new
tables.
This works fine except for two tables that are used in queries which are
comparing the new and old tables. For these two tables, I get the warning
message the table can not be unlinked and is in use by another process. By
the time I execute this procedure, all recordsets and forms are closed…
except for the two queries that acting on the tables.
My question is: Is there a way shut down the queries until I can update the
tables, or some other work around. I guess I could always set up a couple of
routines to purge and then copy data from one table to the next, but simply
deleting and renaming is so much cleaner.
Your help is appreciated in advance.
On Error Resume Next
DoCmd.SetWarnings False
For i = 0 To 5
strOldTableName = "HQ" & DataFileArray(i) & "_OLD"
strNewTableName = "HQ" & DataFileArray(i)
DoCmd.DeleteObject acTable, strOldTableName
DoCmd.Rename strOldTableName, acTable, strNewTableName
DoCmd.TransferDatabase acImport, "dBase 5.0", HQDataPath,
acTable, DataFileArray(i), "HQ" & DataFileArray(i)
Next
MsgBox "The Database has been updated"
On Error GoTo 0
DoCmd.SetWarnings True
The_End:
DoCmd.RunCommand acCmdRefresh
End
have two versions of... one new and one old, ie. HQMembers & HQMembers_OLD.
In my procedure I wish to update the database by deleting the “_OLD†tables,
rename the Current Tables by appending the “_OLDâ€, and then import six new
tables.
This works fine except for two tables that are used in queries which are
comparing the new and old tables. For these two tables, I get the warning
message the table can not be unlinked and is in use by another process. By
the time I execute this procedure, all recordsets and forms are closed…
except for the two queries that acting on the tables.
My question is: Is there a way shut down the queries until I can update the
tables, or some other work around. I guess I could always set up a couple of
routines to purge and then copy data from one table to the next, but simply
deleting and renaming is so much cleaner.
Your help is appreciated in advance.
On Error Resume Next
DoCmd.SetWarnings False
For i = 0 To 5
strOldTableName = "HQ" & DataFileArray(i) & "_OLD"
strNewTableName = "HQ" & DataFileArray(i)
DoCmd.DeleteObject acTable, strOldTableName
DoCmd.Rename strOldTableName, acTable, strNewTableName
DoCmd.TransferDatabase acImport, "dBase 5.0", HQDataPath,
acTable, DataFileArray(i), "HQ" & DataFileArray(i)
Next
MsgBox "The Database has been updated"
On Error GoTo 0
DoCmd.SetWarnings True
The_End:
DoCmd.RunCommand acCmdRefresh
End