1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: MS Access 2007 OnLoad Event firing twice

Discussion in 'Software Development' started by Access07, Apr 9, 2008.

Thread Status:
Not open for further replies.
  1. Access07

    Access07 Thread Starter

    Joined:
    Mar 28, 2008
    Messages:
    5
    I have a form that I set the recordsource in the Form Open Event. When this code line executes (Me.Recordsource = strSQL), the program flow skips the following line items in the Open procedure and immediately starts running the Load Event procedure. When the Load Event finishes, the program flow jumps back to the Open Event, finishing the remaining line items and then proceeds to the Load Event (as it should) starting that event all over again.

    What may be causing this?
     
  2. Access07

    Access07 Thread Starter

    Joined:
    Mar 28, 2008
    Messages:
    5
    Well I used this phenomenon to my advantage. In the form's Open Event I parsed some info and then set an integer variable to 0. Then the me.recordsource = strSQL executes and the program jumps into the Load event. After the Load event finishes, the OnCurrent event fires. I simply bracketed all the OnCurrent code with "If intVar = 1 Then ... End If" so it doesn't execute. Then the program jumps back to the Open Event. I then set the integer variable to 1 and open a recordset clone to find the record I am interested in and set the bookmark (me.bookmark = rs.bookmark) forcing the OnCurrent event to fire again, thus skipping the Load Event. This time intvar is 1 and all the OnCurrent code executes from now on.
    From everything I have read your not supposed to be able to navigate records in the Open Event, but I am currently doing it. Hopefully this is purposeful and not a bug and can be exploited further. If it is a bug, well I will be fixing code later on.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Solved Access 2007
  1. leachim
    Replies:
    0
    Views:
    633
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/702130

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice