Backing up a BackEnd

G

Gary

Sory for the double post i wasn't sure where to post this question.

Is there a neat clean way to Back up the
backEnd that resides on a server from
within my FrontEnd. In other words, from
a button on a form. Nothing Fancy, just
backup the data.

Thanks
 
G

Gary

Thanks Roger,
That's Exactly what I was about to ask.
I'll have a look at the code & see if I can
figure it out for my office environment.

I remember reading somwhere that there are
some hazards in compacting a backend on the
Server. Have you had any experiences with this.
BTW I'm developing in A2K & delivering to A2002

Thanks so much!
 
G

Gary

Forgive me Roger, but I'm not the greatest programmer.
I can't seem follow all the logic when the form opens there's
code that makes or copy or links to the Detail table in the New DB???
Then when i exit everything gets deleted.
This seems to be a little over my head for just a simple backing up
of a Bakend.
Anyway thanks for the suggestion.
 
R

Roger Carlson

Don't apologize. That stuff is not really about compacting. That is code
that actually creates the backend database, then links table to the FE.
That stuff is there ONLY so I won't have to provide a BE for the sample.
You can ignore that for the compacting part.

Actually, the compacting and backing up code is simply this (found behind
the Compact button):
'--------------------------------
Private Sub cmdCompact_Click()
On Error GoTo Err_cmdCompact_Click

Dim LinkPathFile As String
Dim LinkPath As String
Dim LinkFile As String
Dim FileWithoutExtention As String

'uses the findsource, getpath, and getfile functions
'to determine the path and filename of the linked database
LinkPathFile = Mid(FindSource(), 11)
LinkPath = getpath(LinkPathFile)
LinkFile = getfile(LinkPathFile)
FileWithoutExtention = Left(LinkFile, InStr(LinkFile, ".") - 1)

'Compact the Back-End database to a temp file.
DBEngine.CompactDatabase LinkPath & LinkFile, LinkPath &
FileWithoutExtention & "Temp.mdb"

'Delete the previous backup file if it exists.
If Dir(LinkPath & FileWithoutExtention & ".bak") <> "" Then
Kill LinkPath & FileWithoutExtention & ".bak"
End If

'Rename the current database as backup and rename the temp file to
'the original file name.
Name LinkPath & LinkFile As LinkPath & FileWithoutExtention & ".bak"
Name LinkPath & FileWithoutExtention & "Temp.mdb" As LinkPath & LinkFile

Exit_cmdCompact_Click:
Exit Sub

Err_cmdCompact_Click:
MsgBox Err.Description
Resume Exit_cmdCompact_Click

End Sub
'--------------------------------

There are three other subroutines that are needed: "findsource", "getpath",
and "getfile" functions. These functions automatically find the path to the
BE, and the path and filename of the FE, but if you know exactly what the
paths and file names are, you can hard code them instead of using thise
functions.

That's really all there is

However, now that I think about it, you can do the whole thing without the
compact at all. The FileCopy command will copy the backend. So you could
just do this:
'--------------------------------
Private Sub backupbackend_Click()
On Error GoTo Err_backupbackend_Click

Dim LinkPathFile As String
Dim LinkPath As String
Dim LinkFile As String
Dim FileWithoutExtention As String

'uses the findsource, getpath, and getfile functions
'to determine the path and filename of the linked database
LinkPathFile = Mid(FindSource(), 11)
LinkPath = getpath(LinkPathFile)
LinkFile = getfile(LinkPathFile)
FileWithoutExtention = Left(LinkFile, InStr(LinkFile, ".") - 1)

'Copy the Back-End database to a file with current date.
FileCopy LinkPath & LinkFile, LinkPath & FileWithoutExtention &
Format(Date, "mm-dd-yyyy") & ".mdb"

Exit_backupbackend_Click:
Exit Sub

Err_backupbackend_Click:
MsgBox Err.Description
Resume Exit_backupbackend_Click

End Sub
'--------------------------------
--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Top