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

Independent Software Vendors: 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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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