DoCmd.CopyDatabaseFile (Access)

Copies the database connected to the current project to a Microsoft SQL Server database file for export.

The file name of the copy must have an .mdf extension to be recognized as a SQL Server database file. The method fails and an error occurs if any of the following occurs:

CopyDatabaseFile (DatabaseFileName, OverwriteExistingFile, DisconnectAllUsers)


DoCmd.CopySQLDatabaseFile _ 
 DatabaseFileName:="C:\Export\Sales.mdf", _ 
 OverwriteExistingFile:=True, _ 
 DisconnectAllUsers:=True

Arguments

The following argument is required

DatabaseFileName (String) - The name of the file (and path) to which the current database is copied. If no path is specified, the current directory is used.

Optional arguments

The following arguments are optional

OverwriteExistingFile (Boolean) - Determines whether Microsoft Access overwrites the file specified by DatabaseFileName. True to overwrite the existing file. If the file doesn't already exist, this argument is ignored.

DisconnectAllUsers (Boolean) - Determines whether Access disconnects any users connected to the current database to make the copy. True to disconnect other users before copying the database file.