Archiving Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need some help, I am trying to find out if there is any way to automate
an archiving process that I want to have for my database.
I just need to archive one table but the table has several months data that
i want to
have the user, when ready, be able to move all data for that particular
month and make a
seperate database and give it a particular name. Please Help
 
Hi Justin!

Try something like this :

Dim MyQuery As QueryDef
Dim strSQL As String
Dim strQueryName As String
Dim StrNewDBPath As String
Dim DefaultWorkspace As Workspace
Dim NewDatabase As Database

strSQL = "SELECT * FROM
WHERE <Criteria>"
StrNewDBPath = <something>.mdb"
Set DefaultWorkspace = DBEngine.Workspaces(0)
Set NewDatabase = DefaultWorkspace.CreateDatabase(StrNewDBPath,
dbLangGeneral)
NewDatabase.Close
strQueryName = Now
Set dbsCurrent = CurrentDb
Set MyQuery = CurrentDb.CreateQueryDef(strQueryName, strSQL)
DoCmd.TransferDatabase acExport, DB_TYPE, StrNewDBPath, acTable,
strQueryName, "OFSTAT2"
CurrentDb.QueryDefs.Delete strQueryName
strSQL = "DELETE * FROM
WHERE <Criteria>"
CurrentDB.Execute strSQL
 
Back
Top