Access 2016 Compile error (1 Viewer)

frankt68

Registered User.
Local time
Today, 01:39
Joined
Mar 14, 2012
Messages
90
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:

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. :eek:
 

Minty

AWF VIP
Local time
Today, 00:39
Joined
Jul 26, 2013
Messages
10,373
In the VBA editor and click on the "Tools" menu then select "References" under that.
It should highlight a MISSING library. This is the one you need to add/find.
 

frankt68

Registered User.
Local time
Today, 01:39
Joined
Mar 14, 2012
Messages
90
Thank you. That works!
 

Users who are viewing this thread

Top Bottom