Solved

Using VBA, how do I get an option frame value from a pop-up dialog form back into main form?

Posted on 2011-09-21
4
594 Views
Last Modified: 2012-05-12
Hi Experts,

I have a main form with a [Send Email] button. This button opens a pop-up dialog form with the option to select:

Option value 1: "Send file as attachment"
Option value 2. "Send file as link"

The user is supposed to make a choice here first and close the pop-up dialog with a [Close] button. Then and only then, the email is sent accordingly.

My problem: The code in my main form keeps running passed the docmd.openform dialog and doesn't wait for this pop-up dialog to be closed.

I have created a Public variable MyFileSendChoice where the option is stored. The main form code picks up the choice from this public variable MyFileSendChoice.

    DoCmd.OpenForm "frm_Attach_or_Link"      'this is the popup dialog
    
    If MyFileSendChoice = InsertEmailLink Then

        'send email with link here...

    Else

        'send email with attachment here...

    End If

Open in new window



(The code for sending the email itself is not the problem.)

Can you help? Thanks.

Public MyFileSendChoice As EmailFileDistribution     'Attach file or Insert Link in email
Public Enum EmailFileDistribution
    AttachToEmail
    InsertEmailLink
End Enum

Open in new window

0
Comment
Question by:TicketMan
  • 3
4 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 36572984
You need to specify acDialog for the code to pause:

DoCmd.OpenForm "frm_Attach_or_Link" ,,,,,acDialog
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 36573033
<The main form code picks up the choice from this public variable MyFileSendChoice....>

Another alternative would be to send the email from an event on the Popup form instead of the main form

But in terms of halting the code until the dialogbox closes, as stated above, you need to specify acDialog as the WindowMode parameter (even if the form properties are modal/popup).

DoCmd.OpenForm "frm_Attach_or_Link" ,,,,,acDialog 

Open in new window


acDialog will pause the code in the procedure that opens the form, and then resume at the next line once the dialog form is closed.
0
 

Author Closing Comment

by:TicketMan
ID: 36573097
Brilliant! Many thanks!!!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36573108
Glad to help :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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