Results 1 to 5 of 5

Thread: backup .mdb file

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    2

    Post

    I would like to enable the user of my app. to backup the Access (.mdb) database file to floppy each day (it's pretty small for now). Is there an API call or built in function to do this? Thank you in advance.

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Location
    SLOVENIA, Europe
    Posts
    110

    Post

    1. You can use FileCopy function.
    2. You can use Shell function to run some archive programs (winzip, pkzip, ...) with parameters that will zip file and copy it to floppy!

    Ermin

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post ...or

    ...or you can drop common dialog control on your form and then use DAO and a modified version of the following code to ask the user where to place the backup copy and then create the backup copy via DatabaseCompact which has the advantage of creating the smallest possible file.
    Code:
    Public Function CreateDB() As Boolean
    '***************************************************************************
    'Purpose: Create the extract database via CompactDatabase
    'Inputs:  None
    'Outputs: None
    '***************************************************************************
    
        Dim wrkDefault As Workspace
    
        frmExtract.dlgMDB.CancelError = True
        frmExtract.dlgMDB.DefaultExt = "MDB"
        frmExtract.dlgMDB.Filter = "Test Case Database Files(*.MDB)|*.MDB"
        
        On Error Resume Next
        
        frmExtract.dlgMDB.Flags = cdlOFNOverwritePrompt Or cdlOFNExtensionDifferent Or cdlOFNPathMustExist
        frmExtract.dlgMDB.Action = 2
        
        If Err = 32755 Then 'Cancel
            Err.Clear
            CreateDB = False
            Exit Function
        End If
        
        On Error GoTo ErrorRoutine
        
        ' Get default Workspace.
        Set wrkDefault = DBEngine.Workspaces(0)
        ' Make sure there isn't already a file with the name of
        ' the new database.
        If Dir(frmExtract.dlgMDB.FileName) <> "" Then
            Kill frmExtract.dlgMDB.FileName
        End If
        
        g_dbRWTU.Close
        DBEngine.CompactDatabase "c:\rwt\data\rwtu.mdb", frmExtract.dlgMDB.FileName
        
        CreateDB = True
        Exit Function
        
    ErrorRoutine:
    
        CreateDB = False
        DisplayError "CreateDB", "Error", vbCritical
    
    End Function
    To use the above you will want to delete the g_dbRWTU.Close
    line, change the hard-coded database name in the CompactDatabase line, and change the ErrorRoutine to suit yourself.

  4. #4
    Lively Member
    Join Date
    Jun 1999
    Posts
    120

    Post

    from ermingut, to use the pkzip utility with the
    Shell function, an example is shown below:

    ret = Shell("c:\utils\pkzip a:\BkUp c:\MyMdb\MyMdb.mdb")

    Caution: vb or vba does not wait for the Shell command
    to finish its process (i.e. it goes straight
    to the next program line)

    hope this helps...


  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    2

    Post backup .mdb file

    Thanks to all who commented. Very useful information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width