Hi all,
I have created a database for my girlfriend to use at work to create quotes, she wants to be able to run it from a USB drive on both her work PC & her home laptop, she also wants to be able to back her database up at the push of a button.
On the databases I have created at work I run them as split databases which are stored on a server, the code I use on a button works (I think I might have found it on here & modified it a bit, thanks to the original creator of the code) fine but I created a folder on a USB with the same name as hers (both the drive name & folder name) & the drive has the same drive letter assigned but her database that I split won't work on her laptop, I presume the backend is also picking up the PC name as well as the drive name & folder name.
This is the code I use on my databases
Is there a way to change the code so a split database can still be backed up on her USB on both her home laptop & her work PC & for the database to work when split when plugged into both computers? Or is there a way to backup a non-split database if that will make it work?
I have created a database for my girlfriend to use at work to create quotes, she wants to be able to run it from a USB drive on both her work PC & her home laptop, she also wants to be able to back her database up at the push of a button.
On the databases I have created at work I run them as split databases which are stored on a server, the code I use on a button works (I think I might have found it on here & modified it a bit, thanks to the original creator of the code) fine but I created a folder on a USB with the same name as hers (both the drive name & folder name) & the drive has the same drive letter assigned but her database that I split won't work on her laptop, I presume the backend is also picking up the PC name as well as the drive name & folder name.
This is the code I use on my databases
Code:
Private Sub Button_Backup_Click()
Dim str As String
Dim buf As String
Dim MD_Date As Variant
Dim fs As Object
Dim source As String
Const conPATH_FILE_ACCESS_ERROR = 75
On Error GoTo Backup_Button_Backup
'buf = Back Up Folder
'buf is created if it does not exist
'CurrentProject.Path = F:\Access Quoting\Back End
buf = CurrentProject.Path & "\Backups\"
MkDir buf
Resume Backup_Button_Backup
Backup_Button_Backup:
'Use yyyy-mm-dd hh-mm-ss as folder name. Change as needed.
MD_Date = Format(Date, "yyyy.mm.dd ") & Format(Time, "- hh.mm")
str = CurrentProject.Path & "\Backups\" & MD_Date
'Source = where the data is stored
source = CurrentProject.Path & "\Back End\"
MkDir str
Set fs = CreateObject("Scripting.FileSystemObject")
'Change the file extension as needed
fs.CopyFile source & "*.accdb", str
Set fs = Nothing
MsgBox "Access Quoting database backup " & vbCrLf & MD_Date & vbCrLf & "Completed successfully! Press Ok to close", _
vbInformation, "Backup Successful"
Exit_Button_Backup:
DoCmd.Quit
Exit Sub
Err_Button_Backup:
If Err.Number = conPATH_FILE_ACCESS_ERROR Then
MsgBox "The following Path, " & str & ", already exists or there was an Error " & _
"accessing it!", vbExclamation, "Path/File Access Error"
Else
MsgBox Err.Description, vbExclamation, "Error Creating " & str
End If
Resume Exit_Button_Backup
End Sub
Is there a way to change the code so a split database can still be backed up on her USB on both her home laptop & her work PC & for the database to work when split when plugged into both computers? Or is there a way to backup a non-split database if that will make it work?