FileCopy a back-end database

  • Thread starter Thread starter JJ
  • Start date Start date
J

JJ

How do I tell it to back up the backend database, and not the frontend,
without having the user enter the path and database name. I would like it to
have something simial to CurrectDBPath, mabey CurDBBEPath.

Also, I have them select a folder to copy the file to, from the Browse
Folder menu, but that didn't work because it does not end with a backslash
and so it thinks that it is the file. Is there a fix for this?

Private Sub cmdBackup_Click()
Dim SourceFile, DestinationFile

SourceFile = CurrentDBPath
DestinationFile = CurrentDBDir
FileCopy SourceFile, DestinationFile

End Sub


Funtions are below:


Function CurrentDBDir() As String

Dim strDBPath As String
Dim strDBFile As String
strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)
CurrentDBDir = Left(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function

Function CurrentDBPath() As String

Dim strDBPath As String
Dim strDBFile As String
strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)
CurrentDBPath = Left(strDBPath, Len(strDBPath))
End Function
 
You can determine the name of the back-end database by looking at the
Connect property of any of the linked tables.

It'll look like ;DATABASE=<full path to backend database>, so all you need
to do is start at the 11th position of the string to get the details.
 
Thanks for the help, butI don't know what you're talking about. Could you
explain a little further?
 
First, if you're using Access 2000 or 2002, you'll need to ensure you have a
reference set to DAO. With any code module open, select Tools | References
from the menu bar, scroll through the list of available references until you
find the one for Microsoft DAO 3.6 Object Library, and select it.

For the sake of argument, I'm going to assume that you've got a table
MyTable in your database that's linked to another database.

To find out the database in which MyTable really resides, use:

Dim strDatabasePath As String

strDatabasePath = Mid$(CurrentDb().TableDefs("MyTable").Connect, 11)
 
Thanks


Douglas J. Steele said:
First, if you're using Access 2000 or 2002, you'll need to ensure you have a
reference set to DAO. With any code module open, select Tools | References
from the menu bar, scroll through the list of available references until you
find the one for Microsoft DAO 3.6 Object Library, and select it.

For the sake of argument, I'm going to assume that you've got a table
MyTable in your database that's linked to another database.

To find out the database in which MyTable really resides, use:

Dim strDatabasePath As String

strDatabasePath = Mid$(CurrentDb().TableDefs("MyTable").Connect, 11)
 
Back
Top