Solved

OpenForm in VBA

Posted on 2009-04-02
5
587 Views
Last Modified: 2013-11-28
I am trying to open a form in VBA, have the user double click on a row, get a value from that row and use it in an underlying form.  Problem is that even if I set the form properties to Modal = Yes and Popup = Yes, the program doesn't wait for the form to close, the code continues with the open form in the background.  I need for the form to be opened and the code to "wait" until one way or another that form is closed.  Any ideas?
DoCmd.OpenForm ("users")
            varfilter = "[USER] =" + "'" + VSelUser + "'"
 
VSelUser is set during the dblclick event in the "users" table.

Open in new window

0
Comment
Question by:MelGee
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24055608
Double clicking on the row to open a related record is not the standard way of opening a related form.
(This is counter intuitive because a user must be "Told" that this will happen)
Hence the issues you are having.
Use a button instead.

Dim Sub YourButton_Click()
...
varfilter = "[USER] =" + "'" + VSelUser + "'"
docmd.OpenForm "YourForm",,,varfilter
end sub
0
 
LVL 11

Expert Comment

by:mildurait
ID: 24056145
You could break your code up into two parts, and then fire the second part from the close event of the 2nd form.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 50 total points
ID: 24060053
<even if I set the form properties to Modal = Yes and Popup = Yes>
This is effectively making a Dialog Box.

However if you truly want to suspend everything outside of that form until it closes, you need to specify the acDialog option in the Open Form command (regardless of "Modal = Yes and Popup = Yes", which doesn't quite do the trick).

This WILL pause the execution of your code in the current procedure while the popup form is open:

       DoCmd.OpenForm ("users"),,,,,acDialog   '<---- use the acDialog option

The code execution will resume on the next line once the popup form closes.

0
 

Author Closing Comment

by:MelGee
ID: 31566033
You hit the nail on the head.  Thanks!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 24062120
Glad to help out :-)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question