Solved

OpenForm in VBA

Posted on 2009-04-02
5
566 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now