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

Recommended Answers

All 3 Replies

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"

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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.