Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Stopping Code Execution Until a Form Closes (2003)

    I have part of the code in a function that, if a condition is verified, opens a popup, modal form and then, upon closing said form, should process the global variable(Conta) set by choosing an option button on the form.
    <pre>.........
    If LETT < e Then
    DoCmd.OpenForm "CounterReset"
    Select Case Conta
    Case 1
    a = LETT + 10 ^ (Int(Log10(e))) - e
    Case 2
    a = LETT - Nz(DLookup("inLetT", tab2, "startdate = #" & Format(gio, "mm/dd/yyyy") & "#"), e)
    Case Else
    Exit Function
    End Select
    Else
    ........</pre>


    Problem is the code in the function doesn't wait for the form to close; how can I stop code execution until I get the global variable value upon closing the form? I tried using DoEvents to no avail.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping Code Execution Until a Form Closes (2003)

    Try

    DoCmd.OpenForm FormName:="CounterReset", WindowMode:=acDialog

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping Code Execution Until a Form Closes (2003)

    Thank you Hans,
    Perfect as usual <img src=/S/smile.gif border=0 alt=smile width=15 height=15> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping Code Execution Until a Form Closes (2003)

    Sorry Hans for the belated reply <img src=/S/blush.gif border=0 alt=blush width=15 height=15>, but I've just found out that if I open the form in dialog mode, all the code in the function after
    DoCmd.OpenForm FormName:="CounterReset", WindowMode:=acDialog
    doesn't execute once I close the form, how can I return code execution back to the function once I close the form?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping Code Execution Until a Form Closes (2003)

    Where is the code containing the line

    DoCmd.OpenForm FormName:="CounterReset", WindowMode:=acDialog


    stored? If outside the CounterReset form itself, the code should continue after the user closes the form (unless an error occurs). I have just now tested it again to make absolutely sure, and it works.

    Looking forward to your reply in the summer of 2010! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping Code Execution Until a Form Closes (2003)

    You're right, as usual <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22>
    The code does execute after
    DoCmd.OpenForm FormName:="CounterReset", WindowMode:=acDialog
    but not if you step through code, that's what threw me off yesterday <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>
    <img src=/S/yep.gif border=0 alt=yep width=15 height=15> <img src=/S/time.gif border=0 alt=time width=32 height=48>is of the essence

Posting Permissions

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