hi, I am needing assistance. The below code copies the DB to the C:\ and P:\ drive, however when opening the copied DB it runs through the "You are opening up the database from it's root directory..." on both drives and of course the DB doesn't open for use. It appears to not recognize that it is located on the c:\ or p:\ drive, I am not sure what I have wrong with my coding. When I remove the "Or Left(getdbpath, 3) <>"p:\" it works fine. but the OR seems to make it not work properly.
Can someone help me out, please?
If Left(GetDBPath, 3) <> "c:\" Or Left(GetDBPath, 3) <> "p:\" Then MsgBox ("You are opening up the database from it's root directory, a copy of the database will be copied to your desktop. Click OK below to begin copying.")
On Error Resume Next
Kill "C:\Users\Public\Desktop\CM MAT 2.0 USERCOPY.accdb"
Kill "C:\Users\Public\Desktop\Backup of CM MAT 2.0 USERCOPY.accdb"
Kill "C:\Users\Public\Desktop\Backup of Backup of CM MAT 2.0 USERCOPY.accdb"
Kill "C:\Users\Public\Desktop\Backup of Backup of Backup of CM MAT 2.0 USERCOPY.accdb"
oldPath = "\\vcocfscl01\okcshare\Operations Management\DEPART TOOLS\MAT\Collateral Management\" 'Folder file is located in
UserLogIn = GetUserName
newPath = "C:\Users\" & UserLogIn & "\Desktop\" 'Folder to copy file to
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath & "CM MAT 2.0 USERCOPY.accdb", newPath & "CM MAT 2.0 USERCOPY.accdb"
Kill "P:\CM MAT 2.0 USERCOPY.accdb"
Kill "P:\Backup of CM MAT 2.0 USERCOPY.accdb"
Kill "P:\Backup of Backup of CM MAT 2.0 USERCOPY.accdb"
Kill "P:\Backup of Backup of Backup of CM MAT 2.0 USERCOPY.accdb"
oldPath = "\\vcocfscl01\okcshare\Operations Management\DEPART TOOLS\MAT\Collateral Management\" 'Folder file is located in
UserLogIn = GetUserName
newPathp = "P:\"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath & "CM MAT 2.0 USERCOPY.accdb", newPathp & "CM MAT 2.0 USERCOPY.accdb"
Set fs = Nothing
DoCmd.Close acForm, "CK_DB_Version", acSaveYes
MsgBox ("Database is copied to your desktop, database will now be closed. Please re-open db from your desktop.")
Application.Quit