Hi!
I was forced to start using Office 365. So now I'm using Access 2016 and Windows 10.
I encountered a problem when using one of the files. The file is set to save a copy with the name and the current date at startup (AutoExec macro). In 2010, everything worked perfectly, but in the 2016 version the error "Compile error: Can't find project or library" occurs.
The code is:
and the error points to Date.
Could someone please explain what is wrong? I do not have much experience with Access.
I was forced to start using Office 365. So now I'm using Access 2016 and Windows 10.
I encountered a problem when using one of the files. The file is set to save a copy with the name and the current date at startup (AutoExec macro). In 2010, everything worked perfectly, but in the 2016 version the error "Compile error: Can't find project or library" occurs.
The code is:
Code:
Public Function fMakeBackup() As Boolean
'izdela varnostno kopijo
Dim Source As String
Dim Target As String
Dim retval As Integer
Source = CurrentDb.Name
Target = "C:\Users\Username\FileName_" 'this is not the real path!
Target = Target & Format([B][COLOR="Red"]Date[/COLOR][/B], "yyyy-MM-dd") & " "
Target = Target & Format(Time, "hh-mm") & ".accdb"
' create the backup
retval = 0
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
retval = objFSO.CopyFile(Source, Target, True)
Set objFSO = Nothing
End Function
and the error points to Date.
Could someone please explain what is wrong? I do not have much experience with Access.