Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup to floppy 1

Status
Not open for further replies.

zorch

IS-IT--Management
Feb 27, 2001
9
0
0
GB
Ok I know this is probably stupid obvious, but what is the best way to backup my database to floppy & is it possible to have it autosave to floppy say every hour?
At the moment I'm using explorer to drag it over to the floppy.
Thanks, Tony
 
I assume that your database is less then 1.4M.
You may use copyfile method to copy the database you are using to the floppy disk.
You may also use the "on timer" event of a form to make the copy every hour.

Seaport
 
Sounds like what I need, but is there anywhere on the web that documents how to do this in detail? I'm a total newbie & clueless as to these functions or how to set them up.
Tony
 
Maybe the following example will help.
This code is designed to backup the "Backend" database. It will not backup the file that you have currently open.
The trick to remember is that this code must be triggered from an "Unbound Form", with no other bound forms open or you will receive a "File in use" error (error 70).
You only need to change the value for "strSource" and "strDest" for this code to work.

' *********************** Start Code *********************
Public Sub BackUp()
On Error GoTo Err_Backup
Dim strSource As String, strDest As String, strError As String
Dim strMsgComplete As String, strTitleComplete As String

strMsgComplete = "The Database was Sucessfully Saved to Diskette." _
& vbCrLf & vbCrLf & "Remove Disk from Drive and Place in Safe Location."
strTitleComplete = " Backup Complete"

BeginBackup:
DoCmd.Hourglass True

' Path to where backend database is located
strSource = "C:\Emp_DB\091_be.mdb"

' Destination to where data file is to be copied
strDest = "A:\091_be.mdb"

FileCopy strSource, strDest

'Backup has completed
DoCmd.Hourglass False
MsgBox strMsgComplete, vbInformation + vbOKOnly, strTitleComplete

Exit_Backup:
Exit Sub

Err_Backup:
Select Case Err.Number
Case 61
strError = "The Floppy Disk is full, Cannot Save to this Disk." _
& vbCrLf & vbCrLf & "Insert a New Disk then Click ""OK"""
If MsgBox(strError, vbCritical + vbOKCancel, " Disk Full") = vbCancel Then
DoCmd.Hourglass False
DoCmd.SetWarnings False
Resume Exit_Backup
Else
Resume BeginBackup
End If
Case 70
strError = "The File is currently open." & vbCrLf & _
"The File can not be Backed Up at this time."
MsgBox strError, vbCritical, " File Open"
DoCmd.Hourglass False
DoCmd.SetWarnings False
Resume Exit_Backup
Case 71
strError = "There Is No Disk in Drive" & vbCrLf & vbCrLf & _
"Please Insert Disk then Click ""OK"""
If MsgBox(strError, vbCritical + vbOKCancel, " No Disk") = vbCancel Then
DoCmd.Hourglass False
DoCmd.SetWarnings False
Resume Exit_Backup
Else
Resume BeginBackup
End If
Case Else
Err.Raise Err.Number, Err.Description
Resume Next
End Select

DoCmd.Hourglass False
Resume Exit_Backup

End Sub
' *********************** End Code *********************

HTH
RDH Ricky Hicks

 
Oppss....Very Important!!!!!!!

In the Backup Code I posted, remove all lines the says:

DoCmd.SetWarnings False

I altered the code for this post and should have removed them.

Sorry for any confusion,
RDH

Ricky Hicks

 
Thanks for that - not sure I'm bright enough to understand it tho :)
I hope this is correct, I have cut & pasted the code which you supplied on to the bottom of the code for my form, removed the lines DoCmd.SetWarnings False & altered the destination & source to those of my mdb
How do I then go about triggering the backup? or will it automatically backup to floppy at set intervals?
I really am very new to anything other than playing with a few games & answering my email, so this is very difficult for me. Still my database is ready to go apart from the backup problem.
Cheers, Tony
 
Hmmm......
The problem will be, as stated in earier post, that the code must be triggered from and unbound form with no bound forms open at the time the backup code runs. Getting the "set interval" time for the backup will not be a problem.
If the timer code triggers to determine that it's time to do the backup you would have to close any bound forms either manually or through the use of code before you could trigger the backup code, or an error will occur. This could be done by having a message box appearing with the choice to Backup Yes/No option. I would think this would be annoying to the user.
I use the code I posted to trigger only if there has been any records added or changed by checking this status before the database is closed.

Maybe someone can suggest another way to approach this using the "set interval" method you need.

HTH
RDH Ricky Hicks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top