Autoexec macro unable to Runcode (Error 2425)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Petrol
    New Member
    • Oct 2016
    • 248

    Autoexec macro unable to Runcode (Error 2425)

    My DBMS runs perfectly from the .accdb, and compiles without error. But when I try to run the resulting .accde it fails during the Autoexec macro with Error 2425, “The expression you entered has a function name that [application title] can’t find”.
    The function call is a RunCode to Public Function Startup(), and it is the only action in the Autoexec macro - see attached document. The function is in a standard module “SystemFunction s”.
    Code:
    Public Function Startup()
    '
    '   Initialises global variables, then checks to see if the back end is linked; if so, open Switchboard; if not, open F74
    '
    '  Process:
    '   Get connect string for tbl People from TableDefs
    '   Extract the path to the linked back end from the connect string
    '   Check the Windows directory for the specified path
    '   If it exists, open the main menu; if not, open F74 (which is the only unbound form)
    '
    Dim dbs As Database, tbl As TableDef
    Dim PathStart As Long, BEPath As String
    Set dbs = CurrentDb()
    Set tbl = dbs.TableDefs("People")              '  See if People table is linked
    
    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
    Call LogActivity("opened", "DBMS on " & Currently & "data")      '  Log the fact that the system has been opened
    
    If Not CurrentProject.IsTrusted Then
        MsgBox "The database file EmmausDBMS.accdb needs to be in a trusted location"
        Pause (5)
    Else
        PathStart = InStr(tbl.Connect, ";DATABASE=") + 10
        BEPath = Mid(tbl.Connect, PathStart, 99)    '  Path to BE file from the connect string
        If Len(Dir(BEPath, vbHidden)) > 0 Then        '  If there is a linked back end, ...
            DoCmd.OpenForm "01: Login page"           '     then proceed to let the user log in;
        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
    Debug.Print "Exiting Startup"
    End Function
    The application has been running for over 5 years, and it is only in the last week or so that this problem has surfaced. A backup of the application taken a few weeks earlier still runs perfectly from the .accde. However, there are no changes to either the Autoexec macro or the Startup() function, or to anything called by Startup(), between the two versions.

    Testing reveals that Autoexec can successfully open reports, tables, queries, forms etc, but it can’t open ANY RunCode procedures. I have tried various other functions including do-nothing functions, but it can’t find them.

    I have seen the Post.Bytes post on this subject dated Aug 26 ’19 by Kledki, and the responses by NeoPa and ADezii. NeoPa asked “Is it in a standard module?”. As far as I can tell, it is. The module is listed in the Modules section at the bottom of the Navigation pane, and in any case it hasn’t changed since the project started years ago. Learn.microsoft .com says “To determine whether a Module object represents a standard module or a class module from code, check the Module object's Type property” but doesn’t say just what to look for in the Type property. The Type property for the SystemFunctions module says “Module (Local)”, which doesn’t make clear to me whether it’s a class module or a standard one, but I’ve always assumed that those modules in the bottom of the Navigation pane are standard modules. In any case, whatever type it is in the .accdb it presumably is also in the .accde, and whatever type it was in the accde two weeks ago it presumably still is.

    Since I can’t get at the code of the accde I’m finding it very hard to know how to debug this problem.
    Attached Files
  • Petrol
    New Member
    • Oct 2016
    • 248

    #2
    I'll have another try at attaching the document - it got an error when I posted last time.
    Attached Files

    Comment

    • Petrol
      New Member
      • Oct 2016
      • 248

      #3
      Hmm, maybe Post,Bytes can't handle Word attachments. I'll try a PDF.
      Attached Files

      Comment

      • Petrol
        New Member
        • Oct 2016
        • 248

        #4
        By the way, I have tried -
        • Deleting and rewriting Autoexec and Startup
        • Rebooting the computer
        • Compact and repair
        • Decompile and recompile
        • Tearing my hair out
        - all to no avail.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          Hi Petrol.

          From what you've explained here my only viable idea is that the database has picked up a cprruption somewhere.

          My advice would be to take a working copy, as recent a one as you have that is known not to have this problem, then run a C&R on that (Belt & Braces approach) then take changed pieces of the new one into the good copy & test regularly.

          If it goes wrong at any stage then you know what's different between the working one and the non-working one. Perhaps focus there until you can say very precisely exactly what 'cause's it to fail.

          If it doesn't go wrong at all this will indicate that there was some undefined corruption in your broken version that has been excluded from the latest version just (re)built.

          Good luck :-)

          PS. Another meeting (https://accessusergroup s.org/pacific/event/access-pacific-monthly-meeting-2025-04-03/) tonight for us. 11:30 AM for you I think.

          Comment

          • Petrol
            New Member
            • Oct 2016
            • 248

            #6
            Hmm, yes, I was afraid that might be the solution. Either that or copy everything to a new DB. Long slow process either way :(. But thanks for your thoughts.
            I'll try to get to the meeting, if my soon-starting meeting finishes in time.

            Comment

            • Petrol
              New Member
              • Oct 2016
              • 248

              #7
              OK, I've done that. More detailed testing required, but it seems to open OK now. Thanks again.

              Comment

              Working...