Code Loops

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • which1
    New Member
    • May 2010
    • 1

    Code Loops

    On a form I have a command button that opens a report.
    DoCmd.OpenRepor t stDocName, acPreview
    In th Report_activate I have some code that sets values on the report. As I step through this code and get to the to End Sub and hit F8 it takes me back to the Report_Activate event again. At this point I continue to step through the code for the second time. When I get to End Sub the second time and hit F8 it then opens the report. I noticed it also does this on other forms and reports. When the forms or reports open all the info is correct.
    My question: Why does it loop through the code more than once?

    Thanks in advance for any help.
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    The Activate even is triggered after open, and whenever the form recieves focus.
    When you first open a form, the following events occur in this order:
    Open → Load → Resize → Activate → Current
    I would guess that when debugging, the focus goes from the report to the debug window, then back at some point. You could certainly put a msgbox in the event to determine whether it is fired twice under normal use.

    Comment

    Working...