1

I have the following (pseudo-)code:

public publVar

Sub
    publVar = ""

    OpenForm Form1

    Do until publVar <> ""
        Sleep 100
        DoEvents
    Loop

    'Do Something with publVar
End Sub

It is supposed to stop the execution of the code until a value is assigned to publVar on Form1. There is the option to assign the attribute "Popup" to a form in Access to prevent code from being executed but that didnt work for me. My Question is: Is there a better way to do this in Access?

1 Answer 1

4

The OpenForm Method includes a WindowMode argument. Use acDialog to halt execution until the form has closed.

This should free you of nearly all the code above.

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks, that seems to be what i was looking for. It might be a silly question but is it absolutely reliable if i need 100% consistency (execution must not continue before the scripts on the form finished)?
I have never hit a problem with acDialog yet where execution continued. It is annoying in quite different ways :)
And to return values back form that dialog form, this explains how to do this without using global vars and other messy approaches. kallal.ca/Dialog/Index.html
That looks like a very nice approach. Will try it. And I will also check the other articles on your page, seems very interesting :)
Martin, if you want Albert to get your note, use @ followed by his user name.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.