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
593 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

813 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

13 Experts available now in Live!

Get 1:1 Help Now