JithuAccess
Member
- Local time
- Today, 14:51
- Joined
- Mar 3, 2020
- Messages
- 325
Hello,
Is there any way to create a folder by current month and take Backup of the Database on that folder?
In a button click I want to create a folder for example 2022 Feb and then create a Backup of my Database in that folder like from 01-Feb-2022 to 28-Feb-2022.
On next month I want to create a folder 2022 Mar and then create Backup of my database there.
This is my current code
And this is how my Backups are saved in the folder.
This is working perfect but each month I have to create a New folder by Month and change the code from:
To:
So just wondering whether I can do this more automate
Thank you so much
Is there any way to create a folder by current month and take Backup of the Database on that folder?
In a button click I want to create a folder for example 2022 Feb and then create a Backup of my Database in that folder like from 01-Feb-2022 to 28-Feb-2022.
On next month I want to create a folder 2022 Mar and then create Backup of my database there.
This is my current code
Code:
Dim Source As String
Dim Target As String
Dim retval As Integer
Source = CurrentDb.Name
Target = "M:\Database Backup\2022\Feb 2022\"
Target = Target & Format(Date, "dd-mmm-yyyy") & ".accdb"
retval = 0
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
retval = objFSO.CopyFile(Source, Target, True)
Set objFSO = Nothing
If MsgBox("Are you sure you want to exit the Application?", vbYesNo + vbQuestion) = vbYes Then
DoCmd.Quit
Else
Exit Sub
End If
And this is how my Backups are saved in the folder.
This is working perfect but each month I have to create a New folder by Month and change the code from:
Code:
Target = "M:\Innovation & Policy\Claims & SPU Shared Database\Database Backup\2022\Feb 2022\"
To:
Code:
Target = "M:\Innovation & Policy\Claims & SPU Shared Database\Database Backup\2022\Mar 2022\"
So just wondering whether I can do this more automate
Thank you so much