Hi
i found some code on a website that talks about automatically compacting an Access database. I cannot find any method of replying to them however. So i am asking you if you can tell me where i should put this code. Does it get placed somewhere within my database, or is it external to my Access Database but somewhere within the same network drive?
Here is the segment that i got from the website:
Dim objScript
Dim objAccess
Dim strPathToMDB
Dim strMsg
' ////// NOTE: User must edit variables in this section //////'
' The following lines of code are the only variable that need
' be edited. You must provide a path to the Access MDB which
' will be compacted, but the other path needs only be edited
' if desired (it points to temp files)'
strPathToMDB = "H:\EMSEnt.mdb"
strTempDB = "H:\Comp0001.mdb"'
' ////////////////////////////////////////////////////////////////
' Create Access 97 Application Object
Set objAccess = CreateObject("Access.Application.8"
' For Access 2000, use Application.9
'Set objAccess = CreateObject("Access.Application.9"
objAccess.DbEngine.CompactDatabase strPathToMDB ,strTempDB
Set objScript= CreateObject("Scripting.FileSystemObject"
objScript.CopyFile strPathToMDB , strPathToMDB & "z", True
objScript.CopyFile strTempDB, strPathToMDB, True
objScript.DeleteFile strTempDB
' Clean up
Set objAccess = Nothing
Set objScript = Nothing
thanks...........roddy
i found some code on a website that talks about automatically compacting an Access database. I cannot find any method of replying to them however. So i am asking you if you can tell me where i should put this code. Does it get placed somewhere within my database, or is it external to my Access Database but somewhere within the same network drive?
Here is the segment that i got from the website:
Dim objScript
Dim objAccess
Dim strPathToMDB
Dim strMsg
' ////// NOTE: User must edit variables in this section //////'
' The following lines of code are the only variable that need
' be edited. You must provide a path to the Access MDB which
' will be compacted, but the other path needs only be edited
' if desired (it points to temp files)'
strPathToMDB = "H:\EMSEnt.mdb"
strTempDB = "H:\Comp0001.mdb"'
' ////////////////////////////////////////////////////////////////
' Create Access 97 Application Object
Set objAccess = CreateObject("Access.Application.8"
' For Access 2000, use Application.9
'Set objAccess = CreateObject("Access.Application.9"
objAccess.DbEngine.CompactDatabase strPathToMDB ,strTempDB
Set objScript= CreateObject("Scripting.FileSystemObject"
objScript.CopyFile strPathToMDB , strPathToMDB & "z", True
objScript.CopyFile strTempDB, strPathToMDB, True
objScript.DeleteFile strTempDB
' Clean up
Set objAccess = Nothing
Set objScript = Nothing
thanks...........roddy