Copying a file

Posted on 1999-11-18
Medium Priority
Last Modified: 2010-05-02
I need subroutines to do the following:

1.  A subroutine called "Backup" which will copy the file "hockey.mdb" to "hockey.bak" (replacing it)

2.  A subroutine called "Revert" that will copy the file "hockey.bak" to "hockey.mdb" (replacing it)

3.  A function called TestBackup that will read the time and date stamp on "hockey.bak" and return it (as a string);  if the file "hockey.bak" doesn't exist, it will return "never"

I am not asking for a fully coded version of all of them...just the parts where I have to manipulate the shell (copy files, check timestamp).

I am without documentation, so I am hoping this is fairly trivial.
Question by:scrapdog

Accepted Solution

SLE earned 160 total points
ID: 2218959
Private Sub DoCopy(sSource, sDest)
    FileCopy sSource, sDest
End Sub

Private Function TestBackup(sBackup As String) As String
    TestBackup = "NEVER"
    If Dir(sBackup) <> "" Then
        TestBackup = FileDateTime(sBackup)
    End If
End Function

Put the following in your code:

i) DoCopy App.Path & "\hockey.mdb", App.Path & "\hockey.bak"
ii) DoCopy App.Path & "\hockey.bak", App.Path & "\hockey.mdb"
iii) TestBackup(App.Path & "\hockey.bak") will return date & time or NEVER if it does not exist


Author Comment

ID: 2218963
Excellent...very simple.  Thanks.

Expert Comment

ID: 3093717
thanks guys, works great.

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question