none
What does Access do on startup? RRS feed

  • General discussion

  • Would someone please point me to the web or help page that describes how Access starts a database? I know it checks the autoxxxx routines, but what else does it do. I have this inherited database in which *I* think weird things are happening.


    peter n roth - http://PNR1.com, Maybe some useful stuff

    • Changed type Peter N Roth Wednesday, October 14, 2015 12:11 AM issue resolved, but question not answered
    Thursday, October 8, 2015 4:18 PM

All replies

  • You have three startup points:

    1. The AutoExec macro. A macro named AutoExec (case-insensitive) will be executed automatically.

    2. The startup form in the database settings.

    3. A given macro on the command line to execute.

    Thursday, October 8, 2015 8:12 PM
  • Hi Peter

    Like what weird things?

    Thursday, October 8, 2015 8:14 PM
  • Like executing [data checking] code for the OnExit event of a textbox that is not active on a subform that is not open of a form that is not open. Since I expect something like what Stefan outlined, I declare the observed behavior as “weird”.

    I compiled this before executing on Win 10, Acc2010. Is it possible that I am seeing a compiler intervention?

    At what point does the compiler become active during startup (if it does)?

    How does Access know it has some code integrity before it starts executing?

    At what point are the macros “checked”?

    As I said, inherited app.

    The Switchboard is the opening screen.

    There’s a password screen that opens as part of the Switchboard load event, but I expect that would be allowed...

     


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Thursday, October 8, 2015 9:07 PM
  • Like executing [data checking] code for the OnExit event of a textbox that is not active on a subform that is not open of a form that is not open. Since I expect something like what Stefan outlined, I declare the observed behavior as “weird”.

    Hi Peter,

    Code is not executing spontaneously, at least not with me. When opening the application with Shift key pressed, you can step from the very first line to see where an unexpected routine is called.

    Another point that can give unexpected results is when you have the same procedure-name in different standard modules, without explicit stating in which module to search. In that case Access chooses for you (depending on the current context), and that can be different from what you think.

    Imb.

    Thursday, October 8, 2015 10:37 PM
  • Imb-hb -

    I will try the shift key held down.

    Still, what Access is doing is opaque.

    I assume it starts like

    Create DBEngine

    Create a workspace

                Create the MSysTables

    Error checks

                         ? then what

    Is the kinky way this Database is written throwing Access out of its normal startup?


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Thursday, October 8, 2015 11:32 PM
  • I think I fixed the issue by wrapping the code with "If Me.Dirty then".

    I'd still like to know what the execution path is, tho


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Friday, October 9, 2015 2:15 AM
  • I will try the shift key held down.

    Still, what Access is doing is opaque.

    I assume it starts like

    Create DBEngine

    Create a workspace

                Create the MSysTables

    Error checks

                         ? then what

    Is the kinky way this Database is written throwing Access out of its normal startup?

    Hi Peter,

    When you startup a database while holding down the shift key, Access just gives the you the database window. What is happening until this stage I do not know, but it has always worked ok. In fact I really do not want to know, because I cannot influence that at all.

    More interesting then is the very first macro that is started, or the startup form that is opened. I think there the weird things are programmed. Did you step through this code? Probably yes, because you "fixed" it with 'If Me.Dirty then'.

    It is interesting to see that code.

    Imb.

     

    Friday, October 9, 2015 6:13 AM
  • The startup in this database is to open the “switchboard”, as this is the startup form. During the load, another form is opened to collect the password. The response to that form determines how much more of the switchboard you get to see. OK.

    The switchboard has several buttons that open other forms. I click the button that opens a 3-part form (Form + 2 subforms). This calls a macro which opens the form in Edit mode. The subform of interest has an OnOpen event that does nothing.

    But, it has a textbox control with OnClick and OnExit events which are serviced with VBA code.

    OnClick sets a caption for this textbox, which collects a Date (written before the DatePicker was available).

    OnExit is where I put in some error checking (perhaps this should be somewhere else), and the error checking interrupts the load process with an error, because the date it is checking is past what would be allowed today.

    WHY is the exit event firing? Are the other events also firing?

    Other textboxes on the form are accepting phone numbers, which have the OnClick event. They set initial values to 0. I assume they fire at OnClick, but are they also activated during form Load?

    If I didn’t have the Dependency Checker, I would be completely lost; as it is now, I’m merely confused. http://www.accessdependencychecker.com/


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Friday, October 9, 2015 8:14 PM
  • If you really want to know what's going on with your database, post it on OneDrive and provide a link here.
    Friday, October 9, 2015 8:21 PM
  • Thanks, RunningManHD, but it would take me a bit of time to expunge the confidential data.


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Friday, October 9, 2015 8:25 PM
  • The startup in this database is to open the “switchboard”, as this is the startup form. During the load, another form is opened to collect the password. The response to that form

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Shouldn't the "another" Form be the startup Form and then open the switchboard based on the returned criteria?

    Just takes a click to give thanks for a helpful post or answer.
    Please vote “Helpful” or Mark as “Answer” as appropriate.
    Chris Ward
    Microsoft Community Contributor 2012

    Friday, October 9, 2015 8:46 PM
  • WHY is the exit event firing? Are the other events also firing?

    Hi Peter,

    As RunningMan also said, it is hard to appreciate all details in the right context without knowing the whole code.

    When for some reason you enter a control, the you have to exit it again, and then the Exit event fires.

    Error handling is another thing. It can disturb the process flow tremendously, especially when it not handled in the same routine as where the error originates. For that reason I use a technique where the part that is prone to errors is isolated in a specialized and generalized routine that handles the error optimally. This has gone so far that front ends need no - and have no - additional error handling.

    The initialization of the telephone numbers do no harm. It is just setting a value (or not). You initialize them to 0? For me it makes no sense to calculate with telephone numbers, that is why I use string (with many more possibilities) to represent them. The same holds for bank numbers (IBAN contains characters), social security numbers, street numbers, etc.  

    Imb.

    Friday, October 9, 2015 9:12 PM
  • Thanks, RunningManHD, but it would take me a bit of time to expunge the confidential data.


    peter n roth - http://PNR1.com, Maybe some useful stuff

    You can't make a copy and delete all data from tables?

    Here's a simple procedure to wipe the entire database:

    Function DeleteAllData()
    
        On Error Resume Next
        
        Dim tdf As TableDef
        Dim blnStatus As Boolean
        Dim intResponse As Integer
        Dim strMsg As String
        
        strMsg = "Caution!  You are about to delete all table data in the current database."
        strMsg = strMsg & vbCrLf & vbCrLf & "Proceed?"
        
        intResponse = MsgBox(strMsg, vbExclamation + vbOKCancel, "CAUTION!")
        If (intResponse = vbOK) Then
            Do
                blnStatus = False
                For Each tdf In CurrentDb.TableDefs
                    If (Left(tdf.Name, 4) <> "MSys" And Left(tdf.Name, 4) <> "~TMP") Then
                        CurrentDb.Execute "DELETE FROM " & tdf.Name
                        If (Not blnStatus) Then
                            blnStatus = (DCount("*", tdf.Name) > 0)
                        End If
                    End If
                Next
            Loop While blnStatus = True
            
            strMsg = "All table data has been deleted"
            MsgBox strMsg, vbInformation, "Process Complete"
        Else
            strMsg = "You canceled the delete process.  No data was deleted."
            MsgBox strMsg, vbInformation, "Delete Canceled"
        End If
        
    End Function


    This procedure should take seconds to completely wipe your entire database.  Let us know how you make out.
    Friday, October 9, 2015 10:06 PM
  • Of course. but as I say, this has "been around" for a while, and folks are "used to it".

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Friday, October 9, 2015 11:18 PM
  • You are having an appreciation of what i am up against.

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Friday, October 9, 2015 11:20 PM
  • Of course! I'll be back...

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Friday, October 9, 2015 11:21 PM
  • https://onedrive.live.com/redir?resid=D6606A3EE4BF95F0!572&authkey=!AHnOXTvuhzP87nY&ithint=file%2caccdb is the link to the back end. In the same folder is FE5l, the front end. The "password" is "staffer" plus two Enter strokes. This a first for me so tell me if you have any trouble.

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Saturday, October 10, 2015 12:41 AM
  • https://onedrive.live.com/redir?resid=D6606A3EE4BF95F0!572&authkey=!AHnOXTvuhzP87nY&ithint=file%2caccdb is the link to the back end. In the same folder is FE5l, the front end. The "password" is "staffer" plus two Enter strokes. This a first for me so tell me if you have any trouble.

    Hi Peter,

    I was unable to open the database, as I am still using A2003.

    Imb.

    Saturday, October 10, 2015 2:37 PM
  • Peter,

    I am working on your database.  It might be good to speak offline to discuss some of my findings and repairs.  Shoot me an email at b1rigley-at-gmail and let's get connected.

    Thanks,

    RM


    Saturday, October 10, 2015 3:57 PM
  • Sorry, Imb-hb, I have included navigation forms in the database, and access won't let me save it in an earlier format. I'll take a shot at deleting those forms and get back to you.

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Saturday, October 10, 2015 6:17 PM
  • I deleted the navigation form, and tried saving the front end as an .mdb in the Save & Publish menu, but no matter what buttons I pressed, Access just sat there and looked at me.


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Saturday, October 10, 2015 6:27 PM
  • Stefan Hoffmann [MVP] wrote:
    >
    > 1. The AutoExec macro. A macro named AutoExec (case-insensitive) will be executed automatically.
    >
    > 2. The startup form in the database settings.
    >
    > 3. A given macro on the command line to execute.
     
    In addition to Stefan's comments this is the order of events:
     
     
    As I read you've worked around the issue by adding If Me.Dirty ... This
    indicates something may be wrong in your program flow, you seem to
    manipulate bound controls when opening the form/subform. Can you do that
    later in the program flow?
     
    --
    Peter Doering [MVP Access]
     
    Monday, October 12, 2015 1:09 AM