Solved: MS Access 2007 OnLoad Event firing twice

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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?
 

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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top