Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Lakewood, New Jersey, USA
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form_Current Executes twice consecutively (Access 2002, SP3)

    I have an Access front-end linked to an Access back-end. The FE contains (for our purposes), a login form, a main menu screen, and a Data Entry form which appear in that order when the database is opened. ie. The user opens the db, sees the login form and logs in. Then sees the main form. Clicks a button and sees the Data Entry form. The very weird issue that I'm having is that when I step through the DE form opening procedures, Form_Current runs twice or three times consecutively for the Data Entry form and for the 2 or 3 subforms that are embedded within it. Has anyone ever experienced this? It's not actually causing problems, but I can't imagine that it doesn't hurt my performance. Why should all that code execute more than once? I really can't see what's causing it.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Form_Current Executes twice consecutively (Access 2002, SP3)

    That's a very common situation - and it's never been clear to me why it happens - so we tend to avoid using the Form_Current event unless we absolutely have to. Perhaps someone else has explored this in more detail - I'd love to know the answer.
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Lakewood, New Jersey, USA
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form_Current Executes twice consecutively (Access 2002, SP3)

    Thanks for your response, Wendell. Unfortunately, phasing out the Form_Current event on this form is difficult to do. However, I just did something that seemed to help. In my Form_Open procedure I was setting a filter on the form's recordset based on a variable that was set when the user logged in. I noticed that the consecutive executions of Form_current were being called when the filter property was changed in Form_Open. I wrote a function to retrieve the value of the variable and created a query which filtered the table by calling the function i.e. the criteria on the ID field is: ALIKE GetLocation & "%". I removed the code in the Form_Open procedure that set the filter and now it seems to only execute Form_Current once!

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form_Current Executes twice consecutively (Access 2002, SP3)

    If you have subforms, you'll also trigger *their* Current event repeatedly. In fact, the current event normally fires multiple times when the form is loading, which is why it's always desireable to use a flag or some kind of test of Me.Visible = True in the OnCurrent event before executing anything.
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Lakewood, New Jersey, USA
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form_Current Executes twice consecutively (Access 2002, SP3)

    Charlotte, I'm sorry for being thick but let me check if I understood. The form_current event fires multiple times while the form is loading. If I put a condition before my code that checks to see if the form is visible, the code will only execute during the last execution of the form_current event?

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form_Current Executes twice consecutively (Access 2002, SP3)

    No, it will only execute when the form is visible, which happens after it loads and also happens every time you move to between records.
    Charlotte

  7. #7
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Lakewood, New Jersey, USA
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form_Current Executes twice consecutively (Access 2002, SP3)

    Thanks Charlotte - that's actually what I meant when I said "last execution" - the last of the series that occurs when the form loads up until the point that it's visible to the user. It sounds like the me.visible check is the way for me to go, then!

Posting Permissions

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