+ Reply to Thread
Results 1 to 4 of 4

Access - run code once form is opened

  1. #1
    Forum Contributor
    Join Date
    08-06-2007
    Posts
    105

    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:

    Please Login or Register  to view this content.
    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
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,859

    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
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    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 Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    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,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

+ 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.6.0 RC 1