+ Reply to Thread
Results 1 to 4 of 4

Thread: Access - run code once form is opened

  1. #1
    Registered User
    Join Date
    08-06-2007
    Posts
    99

    Access - run code once form is opened

    Hello -

    I have a section of my VBA which has stopped working and I'm hoping someone can help me troubleshoot. All other Macros and code work fine inside this database.

    I have code in this section of a form:

    Private Sub Form_Open(Cancel As Integer)
    MsgBox ("Welcome!")
    
    DoCmd.Maximize
    
    End Sub
    It doesn't error our, however it doesn't run either. It seems as if something was turned off where it won't recognize any code inside that section.

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Access - run code once form is opened

    Have you tried erasing the code. Closing the Form and saving it. Open the form and re-enter the code. Sometimes, Access does some strange things. Also before you do the above, consider running Repair and Compact.

    Alan

  3. #3
    Valued Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    270

    Re: Access - run code once form is opened

    In my experience when this happens, it is because the forms properties looses the event procedure tag.

    Check the following:

    Open the form in Design View
    Before Clicking Anything on the form pull up the forms properties window.
    Click the Event Tab
    Find the "On Load" line - Select the "..." button to the right, and click "Code Builder" then click ok.
    This should open the VB Window, click the save button to save your db at this point.
    Close the form, reopen it and it should work again.

    These Directions are based on Access 2007, however there are very similar steps in almost all versions. For whatever reason I have had this happen to me 20 times or so in the last year while doing various test runs on code in the intermediate window. Wish I knew the reason why.

    Hope this helps,

    Dan
    "I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
    If my advice has been helpful to you, then please help me by clicking on the "Star" and adding to my reputation, Thanks!

  4. #4
    Forum Guru ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    traded up
    MS-Off Ver
    2003 & 2010
    Posts
    1,905

    Re: Access - run code once form is opened

    Make sure that, in the form design properties, the "On Open" property still says: [Event Procedure]

    Cheers,
    “To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0