Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Sub CopyCurrentFile()
' Purpose: Function to copy the current database in Access
' Author: John Barnett, handle jrbarnett
' Date: 30th July 2003
' In response to thread702-615057 Notes: It is not possible to copy the current file over via VBA because it is open so the copy fails.
' I should also point out that this code makes no checks to ensure that it won't overwrite any existing file, or that an existing file is read only or has operating system or network security enabled on it which would cause the copy to fail.
Dim strName As String
Dim strNewname As String
Dim strCommandline As String
strName = CurrentDb.Name ' current (source) path
strNewname = CurrentDb.Name ' new name
strNewname = Left$(strNewname, Len(strNewname) - 4) ' take the dot and 3 char extension off.
strNewname = strNewname & "2.mdb" ' so filename.mdb becomes filename2.mdb
strCommandline = Environ("COMSPEC") & " /C COPY " & strName & " " & strNewname ' execute a command to copy the file
' command will read something like:
' C:\WINNT\System32\CMD.EXE /C COPY F:\John\Database.MDB F:\John\Database2.MDB
Shell strCommandline ' run it
End Sub