?
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
Medium Priority
?
598 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
[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
  • 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 2000 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

Industry Leaders: 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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

752 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