My Access database appears to run correctly, and it recompiles without error. However, if I run a Compact and Repair, when the database reopens I get the error message "Invalid databse object reference" - without, unfortunately, mentioning which object it is referring to. See attached screenshot. Then it says either "The expression contains an ambiguous name" or "The expression you entered has a function name that EmmausDBMS can't find", or even "The VBA modules in this database appear to have been saved with errors ..." - in each case without any indication of what expression or function it's talking about or where to find it. The promised 'attempt to recover the errors' doesn't help.
Furthermore, once C&R has encountered (or generated?) the error, it will continue to get it whenever the DB is opened, even if both the Autoexec macro and the module containing the Function Startup() are deleted.
It's Access in MS365 running in Windows 11. Presumably there is an error in the VBA somewhere, but can anyone suggest how to find it? Visual examination fails to find it. This has been happening for about the last week, and all my efforts to find the cause have been fruitless.
Twice now I have copied all the objects to a new database. The C&R and reopen of the new copy runs OK without the macros but with all the tables, forms, reports and modules included, but as soon as I add the Autoexec macro the problem reappears. The Autoexedc macro contains only a RunCode Startup() statement.
I have replaced the original Function Startup() with a dummy one containing only a MsgBox statement, and the error still occurs. Code for both versions is below.
I have no passthrough queries of objects with the same name as a table (both of which were suggestions on another website for this problem).
(Please ignore any illegal space characters in the above code. They are not there in the original, which does compile without error).
Furthermore, once C&R has encountered (or generated?) the error, it will continue to get it whenever the DB is opened, even if both the Autoexec macro and the module containing the Function Startup() are deleted.
It's Access in MS365 running in Windows 11. Presumably there is an error in the VBA somewhere, but can anyone suggest how to find it? Visual examination fails to find it. This has been happening for about the last week, and all my efforts to find the cause have been fruitless.
Twice now I have copied all the objects to a new database. The C&R and reopen of the new copy runs OK without the macros but with all the tables, forms, reports and modules included, but as soon as I add the Autoexec macro the problem reappears. The Autoexedc macro contains only a RunCode Startup() statement.
I have replaced the original Function Startup() with a dummy one containing only a MsgBox statement, and the error still occurs. Code for both versions is below.
I have no passthrough queries of objects with the same name as a table (both of which were suggestions on another website for this problem).
Code:
Public Function startup()
MsgBox "Starting"
End Function
Public Function WasStartup()
'
' 1. initialises global variables, then checks to see if the back end is linked; if so, open Switchboard; if not, open F74
' Process:
' Set global variables for the current user, the computer he is using, and the current back end
' Confirm that the DBMS is in a trusted location
' Check the Windows directory for the specified path (found by function WhichBackEnd)
' If it is currently valid, open the main menu and log the fact that the database has been opened;
' if not, open F74 (which is the only unbound form) to find an available back end
'
gblComputerName = VBA.Environ("USERDOMAIN")
gblComputerUserName = VBA.Environ("USERNAME") ' User name as recorded in the operating system
gblUserName = gblComputerUserName ' User name as recorded in the database, after he has logged on in F01
gblCurrentUser = 0 ' PersonID of current user (initialised to 0 so F74 can tell whether a user has logged in)
Call WhichBackEnd ' WhichBackEnd will find the path to the BE from the connect string and set it in gblBEPath
' (At this stage the connect string only contains the path to the last BE that was opened; it may not currently be open)
If Not CurrentProject.IsTrusted Then
MsgBox "The database file EmmausDBMS.accdb needs to be in a trusted location"
Pause (5)
Else
If Len(Dir(gblBEPath, vbHidden)) > 0 Then ' If there is a linked back end, ...
DoCmd.OpenForm "01: Login page" ' then proceed to let the user log in, and ...
Call LogActivity("opened", "DBMS on " & Currently & "data") ' ... log the fact that the system has been opened.
Else
DoCmd.OpenForm "74: Link to back end" ' otherwise, go find a back end; F74 will then open F01 (because gblCurrentUser= 0)
End If
End If
End Function
Comment