Copy the database connected to the current project to a SQL Server database file for export.
Syntax DoCmd.CopyDatabaseFile(DatabaseFileName, OverwriteExistingFile, DisconnectAllUsers) Key DatabaseFileName The name of the file (and path) to which the current database is copied. default=current directory. OverwriteExistingFile Determines whether Access will overwrite any existing file specified by DatabaseFileName. True to overwrite the existing file. DisconnectAllUsers Determines whether Access disconnects any users connected to the current database in order to make the copy. True to disconnect users.
The file name of the file must have an .mdf extension.
To succeed, Access must be able to lock the destination file and have full access to the source database (no pending design sessions.)
DisconnectAllUsers might fail if any users have an exclusive lock on any database objects.
The current user for the Access project will need system administrator privileges for the database server.
Example
DoCmd.CopySQLDatabaseFile
DatabaseFileName:="C:\Demo\SS64.mdf", _
OverwriteExistingFile:=True,
DisconnectAllUsers:=True
“We could have saved the Earth but we were too damned cheap” ~ Kurt Vonnegut, Jr.