0
BACKUP DATABASE [DATABASE NAME] TO DISK=’\\SERVERNAME\PATH.BAK’
RESTORE DATABASE database_name FROM backup_device WITH RECOVERY

i dont know wheather i should create a query file for the code

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by AndreRet
0

I give you a tips for backup & restore database. you can use copy command like

On Error GoTo err
MkDir "D:\Backup" ' its make a folder named backup
Dim fso As Object, MyFile As Object
Set fso = CreateObject("Scripting.FileSystemObject")

Set MyFile = fso.GetFile(App.Path & "\database.mdb")
MyFile.Copy ("D:\Backup\backup")
MsgBox " Back up sucessfully complete. ", vbInformation

err:
MsgBox "Backup file was already exist", vbInformation, "Alert"

0

I give you a tips for backup & restore database. you can use copy command like

thanks alot for the help. where would u suggest i put the code?

0

Abu, you have to exit the sub before you can go to err: -

MsgBox " Back up sucessfully complete. ", vbInformation

err:

Should be -

MsgBox " Back up sucessfully complete. ", vbInformation
Exit sub

err:

krab-man, you can put this code under a command button, timer etc. Use it when you need to make a backup of the file selected.

Also remember to set a reference to microsoft scripting runtime files under references.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.