Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OpenForm in VBA

Posted on 2009-04-02
5
Medium Priority
?
633 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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