Automatic backups possible (A2003)

Automatic backups possible (A2003)

am 02.04.2008 19:24:26 von PW

Hi,

Is it possible to back up the data.mdb file when the user exits the
executable (.mde)? How would I do that? And also perform a compact
and repair on exit.

The code and data are in separated into data.mdb and code.mde.

Thanks,

-paulw

Re: Automatic backups possible (A2003)

am 02.04.2008 21:03:25 von Larry Linson

Keep one Form Open all the time -- visible or not, but not closeable via the
user interface, and put code to do what you want in the Close event of that
Form. Exit the appication using DoCmd.Quit from a different Form, and that
Form will close along with the others, so the code will execute.

Compact and Repair creates a new file... if disk space is not "at a premium"
you can archive the previous back-end, rename the new one, and re-link the
tables. I'd advise this, just in case something happened to go awry during
the Compact and Repair. If there's a problem with the new one, and that's
what you back up, and have deleted the old one, your chances of recovery are
hindered.

(That said, I have never experienced an error during Compact and Repair of a
working database in 15 years of using Access, but others have reported
corruption being _caused_ by C&R.)

Larry Linson
Microsoft Office Access MVP

"PW" wrote in message
news:74g7v314rj0aqb79c8tajaa8b55d0c0otd@4ax.com...
> Hi,
>
> Is it possible to back up the data.mdb file when the user exits the
> executable (.mde)? How would I do that? And also perform a compact
> and repair on exit.
>
> The code and data are in separated into data.mdb and code.mde.
>
> Thanks,
>
> -paulw

Re: Automatic backups possible (A2003)

am 02.04.2008 22:46:02 von PW

Hi Larry,

>Keep one Form Open all the time -- visible or not, but not closeable via the
>user interface, and put code to do what you want in the Close event of that
>Form. Exit the appication using DoCmd.Quit from a different Form, and that
>Form will close along with the others, so the code will execute.
>

What code would I use to back up the data.mdb?

Thanks!

-paulw



>Compact and Repair creates a new file... if disk space is not "at a premium"
>you can archive the previous back-end, rename the new one, and re-link the
>tables. I'd advise this, just in case something happened to go awry during
>the Compact and Repair. If there's a problem with the new one, and that's
>what you back up, and have deleted the old one, your chances of recovery are
>hindered.
>
>(That said, I have never experienced an error during Compact and Repair of a
>working database in 15 years of using Access, but others have reported
>corruption being _caused_ by C&R.)
>
> Larry Linson
> Microsoft Office Access MVP
>
>"PW" wrote in message
>news:74g7v314rj0aqb79c8tajaa8b55d0c0otd@4ax.com...
>> Hi,
>>
>> Is it possible to back up the data.mdb file when the user exits the
>> executable (.mde)? How would I do that? And also perform a compact
>> and repair on exit.
>>
>> The code and data are in separated into data.mdb and code.mde.
>>
>> Thanks,
>>
>> -paulw
>

Re: Automatic backups possible (A2003)

am 03.04.2008 04:31:53 von Larry Linson

FileCopy... but you'll have to unlink from the BackEnd before you can Copy
it or TransferDatabase, using which you'd have to, or CopyObject, or
TransferDatabase -- for details of which, see Help. It's been a long time
since I created a new Link to a backend database, so the details escape me,
but you use TransferDatabase, and there is good Help on that subject in
Access 2003 Help.

Larry Linson
Microsoft Office Access MVP

"PW" wrote in message
news:33s7v3hehu1h4osgmopvc5d9gajgqja3un@4ax.com...
> Hi Larry,
>
>>Keep one Form Open all the time -- visible or not, but not closeable via
>>the
>>user interface, and put code to do what you want in the Close event of
>>that
>>Form. Exit the appication using DoCmd.Quit from a different Form, and
>>that
>>Form will close along with the others, so the code will execute.
>>
>
> What code would I use to back up the data.mdb?
>
> Thanks!
>
> -paulw
>
>
>
>>Compact and Repair creates a new file... if disk space is not "at a
>>premium"
>>you can archive the previous back-end, rename the new one, and re-link the
>>tables. I'd advise this, just in case something happened to go awry during
>>the Compact and Repair. If there's a problem with the new one, and that's
>>what you back up, and have deleted the old one, your chances of recovery
>>are
>>hindered.
>>
>>(That said, I have never experienced an error during Compact and Repair of
>>a
>>working database in 15 years of using Access, but others have reported
>>corruption being _caused_ by C&R.)
>>
>> Larry Linson
>> Microsoft Office Access MVP
>>
>>"PW" wrote in message
>>news:74g7v314rj0aqb79c8tajaa8b55d0c0otd@4ax.com...
>>> Hi,
>>>
>>> Is it possible to back up the data.mdb file when the user exits the
>>> executable (.mde)? How would I do that? And also perform a compact
>>> and repair on exit.
>>>
>>> The code and data are in separated into data.mdb and code.mde.
>>>
>>> Thanks,
>>>
>>> -paulw
>>

Re: Automatic backups possible (A2003)

am 03.04.2008 04:43:32 von PW

On Thu, 03 Apr 2008 02:31:53 GMT, "Larry Linson"
wrote:

>FileCopy... but you'll have to unlink from the BackEnd before you can Copy
>it or TransferDatabase, using which you'd have to, or CopyObject, or
>TransferDatabase -- for details of which, see Help. It's been a long time
>since I created a new Link to a backend database, so the details escape me,
>but you use TransferDatabase, and there is good Help on that subject in
>Access 2003 Help.
>
> Larry Linson
> Microsoft Office Access MVP

Hmmm. I have no idea how to unlink tables. Way back when I did write
a successful table linking module using Ken Getz's example in his
Access 97 dev guide which still works great for us.

Thanks Larry - your earlier tip seems pretty slick!

-paulw

>
>"PW" wrote in message
>news:33s7v3hehu1h4osgmopvc5d9gajgqja3un@4ax.com...
>> Hi Larry,
>>
>>>Keep one Form Open all the time -- visible or not, but not closeable via
>>>the
>>>user interface, and put code to do what you want in the Close event of
>>>that
>>>Form. Exit the appication using DoCmd.Quit from a different Form, and
>>>that
>>>Form will close along with the others, so the code will execute.
>>>
>>
>> What code would I use to back up the data.mdb?
>>
>> Thanks!
>>
>> -paulw
>>
>>
>>
>>>Compact and Repair creates a new file... if disk space is not "at a
>>>premium"
>>>you can archive the previous back-end, rename the new one, and re-link the
>>>tables. I'd advise this, just in case something happened to go awry during
>>>the Compact and Repair. If there's a problem with the new one, and that's
>>>what you back up, and have deleted the old one, your chances of recovery
>>>are
>>>hindered.
>>>
>>>(That said, I have never experienced an error during Compact and Repair of
>>>a
>>>working database in 15 years of using Access, but others have reported
>>>corruption being _caused_ by C&R.)
>>>
>>> Larry Linson
>>> Microsoft Office Access MVP
>>>
>>>"PW" wrote in message
>>>news:74g7v314rj0aqb79c8tajaa8b55d0c0otd@4ax.com...
>>>> Hi,
>>>>
>>>> Is it possible to back up the data.mdb file when the user exits the
>>>> executable (.mde)? How would I do that? And also perform a compact
>>>> and repair on exit.
>>>>
>>>> The code and data are in separated into data.mdb and code.mde.
>>>>
>>>> Thanks,
>>>>
>>>> -paulw
>>>
>

Re: Automatic backups possible (A2003)

am 03.04.2008 07:54:30 von lyle

On Apr 2, 1:24=A0pm, PW
wrote:
> Hi,
>
> Is it possible to back up the data.mdb file when the user exits the
> executable (.mde)? =A0How would I do that? =A0And also perform a compact
> and repair on exit.
>
> The code and data are in separated into data.mdb and code.mde. =A0
>
> Thanks,
>
> -paulw

Public Sub BackupLinkedMDB()
Dim p$

With DBEngine(0)(0)
TableDefs.Refresh
On Error Resume Next
Err =3D 0
p =3D _
OpenRecordset( _
"SELECT DISTINCT CStr(DataBase) FROM mSysObjects WHERE Type =3D 6")(0)
End With

If Err =3D 0 Then _
BackupMDB p
End Sub

Public Sub BackupMDB(ByVal path$)
Dim a As Access.APPLICATION
Set a =3D New Access.APPLICATION

With a
On Error Resume Next
Err =3D 0
OpenCurrentDatabase path, True
If Err =3D 0 Then _
SaveAsText 6, "", Replace(path, ".", Format(Date, "YYYYDDMMHHNN."))
On Error GoTo 0
CloseCurrentDatabase
End With

Set a =3D Nothing

End Sub

Re: Automatic backups possible (A2003)

am 04.04.2008 19:33:33 von PW

On Wed, 2 Apr 2008 22:54:30 -0700 (PDT), lyle
wrote:

>On Apr 2, 1:24 pm, PW
>wrote:
>> Hi,
>>
>> Is it possible to back up the data.mdb file when the user exits the
>> executable (.mde)?  How would I do that?  And also perform a compact
>> and repair on exit.
>>
>> The code and data are in separated into data.mdb and code.mde.  
>>
>> Thanks,
>>
>> -paulw
>
>Public Sub BackupLinkedMDB()
>Dim p$
>
>With DBEngine(0)(0)
>.TableDefs.Refresh
>On Error Resume Next
>Err = 0
>p = _
>.OpenRecordset( _
>"SELECT DISTINCT CStr(DataBase) FROM mSysObjects WHERE Type = 6")(0)
>End With
>
>If Err = 0 Then _
>BackupMDB p
>End Sub
>
>Public Sub BackupMDB(ByVal path$)
>Dim a As Access.APPLICATION
>Set a = New Access.APPLICATION
>
>With a
>On Error Resume Next
>Err = 0
>.OpenCurrentDatabase path, True
>If Err = 0 Then _
>.SaveAsText 6, "", Replace(path, ".", Format(Date, "YYYYDDMMHHNN."))
>On Error GoTo 0
>.CloseCurrentDatabase
>End With
>
>Set a = Nothing
>
>End Sub

I'll give it a go Lyle. I've never written code like that before!
Very "Getz" like :-)

-paulw