Copy a database

CarlM1975

Registered User.
Local time
Today, 12:44
Joined
Oct 29, 2008
Messages
24
I have the following to copy a database, but its not working any ideas

Sub CreateDatabase()

Dim wrkDefault As Workspace
Dim dbsNew As Database
Dim DateSave, TimeSave
Dim newdb
Dim StoreFolder
Dim dbname As String

DateSave = Format(Date, "ddmmyy")
TimeSave = Format(Time, "hhmm")
newdb = TimeSave & " " & DateSave & " Mould.mdb"
StoreFolder = "C:\Mould\Backup\"

' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)

' Make sure there isn't already a file with the name of the new database.
If Dir(newdb) <> "" Then Kill newdb

' Create a new encrypted database with the specified collating order.

Set dbsNew = wrkDefault.CreateDatabase(StoreFolder & newdb, _
dbLangGeneral, dbEncrypt)

With dbsNew
.Close
End With

'Close the current database
With dbMould
.Close
End With

FileCopy gsDatabase, StoreFolder & newdb

'reopen the database after copying
gsConnect = ""
Set dbWorkspace = DBEngine.Workspaces(0)
Set Mould = dbWorkspace.OpenDatabase(gsDatabase)

GetTheDatabase

MsgBox "The Database has been saved in the Backup Folder", vbCritical, "Save Database"

End Sub
 
When you say it is not working, what section line is it erroring on?

Also what is gsDatabase, gsConnect and GetTheDatabase
 

Users who are viewing this thread

Back
Top Bottom