Can

A

Angeline

Hi There,
Is it possible to create an automatic backup to a database? If so, can
someone enlighten me on how to do it.

I am not a programmer so would really appreciate a 'spoon fed' response.

Thanks!
Angie
 
A

Arvin Meyer

You can write some VB code or Access VBA code to copy and paste the file to
a new name. Or simply comact it. Run it from the Timer event of an Access
form:

Function CompactDatabase(path As String, databaseName As String)
Dim temp As Integer
' Check if file exists
If CheckIfFileExists((path & "\" & databaseName)) Then
DBEngine.CompactDatabase (path & "\" & databaseName), (path &
\newname.mdb")
' Delete Original File
Kill ((path & "\" & databaseName))
Name (path & "\newname.mdb") As (path & "\" & databaseName)
End If
End Function

Function CheckIfFileExists(fileNameAndPath) As Boolean
Dim FileName As String
FileName = Dir(fileNameAndPath)
If Len(FileName) > 0 Then
CheckIfFileExists = True
Else
CheckIfFileExists = False
End If
End Function

Also, have a look at Total Access Agent:

http://www.fmsinc.com/Products/Agent/index.html
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
A

Angeline

Thanks Arvin,
Could you specify please what is the 'timer event' in the access form ?

The VB code you have suggested should be inserted where exactly ? You said
'run it from the Timer event of an Access form'. By this do you mean that I
should add a comman button into the form and insert it the vb code into the
'code builder' between the following: [Private Sub Command1_Click()] and [End
Sub]. Would this work?
 
J

John Vinson

Hi There,
Is it possible to create an automatic backup to a database? If so, can
someone enlighten me on how to do it.

I am not a programmer so would really appreciate a 'spoon fed' response.

Thanks!
Angie

It is not practical to back up an Access database from *within* that
Access database: an open file may not get backed up correctly.

To back up a database you should use some program *outside* of Access
to simply make a copy (on removable media such as a Zip drive or
compact disk). There are a number of good freeware, shareware, or
commercial backup programs available, or you can simply use Windows
Explorer to copy the file to a CD drive. Just be sure that neither you
nor anyone are in it at the time. This process can be automated (with
some difficulty perhaps :-{( ) using Windows Scheduler.

John W. Vinson[MVP]
 
A

Arvin Meyer

Put the code in a module. You can use a form module or a standard module.
Call it from the Timer event of a form. You should set the TimerInterval
property to 60000 so that it will check once a minute and use some code
similar to:

Private Sub Form_Timer()
Dim x

x = Timer ' the Windows internal timer

If x = 10800 Then ' 3:00 AM
Call CompactDatabase("C:\MyFolder", "MyDatabase.mdb")
End If

End Sub

Run this from an open form in another database. Also, I just noticed that my
code compacts into the same name and you want a true backup so you'll need
to use something like:

Function CompactDatabase(path As String, databaseName As String)
Dim temp As Integer
' Check if file exists
If CheckIfFileExists((path & "\" & databaseName)) Then
DBEngine.CompactDatabase (path & "\" & databaseName), (path & Date &
".mdb")
End If
End Function

This will leave you a file in the same folder with the date as a name.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Angeline said:
Thanks Arvin,
Could you specify please what is the 'timer event' in the access form ?

The VB code you have suggested should be inserted where exactly ? You said
'run it from the Timer event of an Access form'. By this do you mean that I
should add a comman button into the form and insert it the vb code into the
'code builder' between the following: [Private Sub Command1_Click()] and [End
Sub]. Would this work?


Arvin Meyer said:
You can write some VB code or Access VBA code to copy and paste the file to
a new name. Or simply comact it. Run it from the Timer event of an Access
form:

Function CompactDatabase(path As String, databaseName As String)
Dim temp As Integer
' Check if file exists
If CheckIfFileExists((path & "\" & databaseName)) Then
DBEngine.CompactDatabase (path & "\" & databaseName), (path &
\newname.mdb")
' Delete Original File
Kill ((path & "\" & databaseName))
Name (path & "\newname.mdb") As (path & "\" & databaseName)
End If
End Function

Function CheckIfFileExists(fileNameAndPath) As Boolean
Dim FileName As String
FileName = Dir(fileNameAndPath)
If Len(FileName) > 0 Then
CheckIfFileExists = True
Else
CheckIfFileExists = False
End If
End Function

Also, have a look at Total Access Agent:

http://www.fmsinc.com/Products/Agent/index.html
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
A

Angeline

Thanks very much Arvin,
I still don't know what the 'timer event' of a form is though. Can you
enlighten me?

Thanks
Angie
AUSTRALIA

Arvin Meyer said:
Put the code in a module. You can use a form module or a standard module.
Call it from the Timer event of a form. You should set the TimerInterval
property to 60000 so that it will check once a minute and use some code
similar to:

Private Sub Form_Timer()
Dim x

x = Timer ' the Windows internal timer

If x = 10800 Then ' 3:00 AM
Call CompactDatabase("C:\MyFolder", "MyDatabase.mdb")
End If

End Sub

Run this from an open form in another database. Also, I just noticed that my
code compacts into the same name and you want a true backup so you'll need
to use something like:

Function CompactDatabase(path As String, databaseName As String)
Dim temp As Integer
' Check if file exists
If CheckIfFileExists((path & "\" & databaseName)) Then
DBEngine.CompactDatabase (path & "\" & databaseName), (path & Date &
".mdb")
End If
End Function

This will leave you a file in the same folder with the date as a name.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Angeline said:
Thanks Arvin,
Could you specify please what is the 'timer event' in the access form ?

The VB code you have suggested should be inserted where exactly ? You said
'run it from the Timer event of an Access form'. By this do you mean that I
should add a comman button into the form and insert it the vb code into the
'code builder' between the following: [Private Sub Command1_Click()] and [End
Sub]. Would this work?


Arvin Meyer said:
You can write some VB code or Access VBA code to copy and paste the file to
a new name. Or simply comact it. Run it from the Timer event of an Access
form:

Function CompactDatabase(path As String, databaseName As String)
Dim temp As Integer
' Check if file exists
If CheckIfFileExists((path & "\" & databaseName)) Then
DBEngine.CompactDatabase (path & "\" & databaseName), (path &
\newname.mdb")
' Delete Original File
Kill ((path & "\" & databaseName))
Name (path & "\newname.mdb") As (path & "\" & databaseName)
End If
End Function

Function CheckIfFileExists(fileNameAndPath) As Boolean
Dim FileName As String
FileName = Dir(fileNameAndPath)
If Len(FileName) > 0 Then
CheckIfFileExists = True
Else
CheckIfFileExists = False
End If
End Function

Also, have a look at Total Access Agent:

http://www.fmsinc.com/Products/Agent/index.html
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Hi There,
Is it possible to create an automatic backup to a database? If so, can
someone enlighten me on how to do it.

I am not a programmer so would really appreciate a 'spoon fed' response.

Thanks!
Angie
 
A

Angeline

John,
Thank you for your response. This particular database will only be used by
one person for the purpose of running a short-term project. There is lots of
data that will be updated everyday and we don't want to risk it being lost,
so we wanted to set up a simple backup procedure where they just need to run
or click something to back it up.

Angie
AUSTRALIA
 
Top