open a form from within a code

K

K. Shoghi

Hi all, I like to open a form in a middle of a code and I want the code to
pause untill the form is closed.
i have used the following code, but it freezes the whole database.

DoCmd.OpenForm "formname"
Do While CurrentProject.AllForms("formname").IsLoaded
Loop

if i step through the code, it works fine, only when i run the function, it
freezes, any help is appreciated.
 
F

fredg

Hi all, I like to open a form in a middle of a code and I want the code to
pause untill the form is closed.
i have used the following code, but it freezes the whole database.

DoCmd.OpenForm "formname"
Do While CurrentProject.AllForms("formname").IsLoaded
Loop

if i step through the code, it works fine, only when i run the function, it
freezes, any help is appreciated.

Simply open the form in dialog.

DoCmd.OpenForm "FormName", , , , , acDialog

Everything will stop until you close the form.
If the form is needed as parameters for a query, code a command button
on the form:
Me.Visible = false

Then close the form from code elsewhere when it's no longer needed.
DoCmd.Close acForm, "FormName"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top