CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    6

    help with FileCopy

    ok,..

    ive been getting a lot of help here lately,..

    i need another,..
    having backups are good right,..?

    can i use the filecopy command to make a backup of my access database and save it to a specified folder on my computer?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: help with FileCopy

    Not while it's open. I'd write a program that is separate from Access.

    Have you tried it? Here's a Compact and Repair, which I run on program start-up.

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    ' Set Reference to Microsoft Jet Runtim Object (JRO)
    '  BROWSE if not found: \program files\common files\system\ado\msjro.dll
      CompactAndRepair (db$)
    End Sub
    
    
    Sub CompactAndRepair(db$)
      Dim jro As jro.JetEngine, xn$
      Set jro = New jro.JetEngine
      Screen.MousePointer = vbHourglass
      xn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\"
      jro.CompactDatabase xn & db, xn & db & "-2"
      If Len(Dir(App.Path & "\" & db & "-2")) > 0 Then
        Kill App.Path & "\" & db
        Do While Len(Dir(App.Path & "\" & db)) > 0
          DoEvents               ' wait for delete
        Loop
        Name App.Path & "\" & db & "-2" As App.Path & "\" & db
        Do While Len(Dir(App.Path & "\" & db)) = 0
        DoEvents        ' wait for copy to complete
        Loop
    End If
    Screen.MousePointer = vbDefault
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured