Gasman
Enthusiastic Amateur
- Local time
- Today, 15:09
- Joined
- Sep 21, 2011
- Messages
- 16,942
Hi all,
I had a function that backed up my backend DB.
I now wish to backup the front end periodically as I make changes.
I created a test sub to call the function. Last change was to make it a sub. Either works from the test sub.
CreateBackup ("FE")
Code is
In the switchboard I have the same call CreateBackup ("FE") and CreateBackup ("BE")
As a function it produced the error Backup.png
So I changed it to a sub and get the second error Backup2.png
Now I know I can create separate subs to call either the function or sub (I'm not fussed which it is) and use these in the switchboard, but is there a way to keep the code to a minimum as I am trying. ?
The switchboard is also shown
TIA
I had a function that backed up my backend DB.
I now wish to backup the front end periodically as I make changes.
I created a test sub to call the function. Last change was to make it a sub. Either works from the test sub.
CreateBackup ("FE")
Code is
Code:
Sub CreateBackup(strDBType As String)
Dim strDBpath As String, ext As String, tmp As String
Dim strPath As String, strBackupPath As String, strDB As String
'tmp = CurrentDb.Name 'or maybe this should be the name of your BE
strDBpath = GetAccessBE_PathFilename("tblUser")
strPath = Left(strDBpath, InStrRev(strDBpath, "\"))
strBackupPath = strPath & "Backup\"
'Will now backup front and back end database
If strDBType = "FE" Then
strDBpath = CurrentDb.Name
End If
strDB = Right(strDBpath, Len(strDBpath) - InStrRev(strDBpath, "\"))
With CreateObject("Scripting.FileSystemObject")
'ext = "." & .GetExtensionName(tmp)
tmp = strBackupPath & Format(Now(), "yyyymmdd_hhnnss") & "_" & strDB
.CopyFile strDBpath, tmp
End With
MsgBox strDBType & " Database saved as " & tmp
End Sub
Code:
Sub test()
CreateBackup ("FE")
End Sub
In the switchboard I have the same call CreateBackup ("FE") and CreateBackup ("BE")
As a function it produced the error Backup.png
So I changed it to a sub and get the second error Backup2.png
Now I know I can create separate subs to call either the function or sub (I'm not fussed which it is) and use these in the switchboard, but is there a way to keep the code to a minimum as I am trying. ?
The switchboard is also shown
TIA