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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

744 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

14 Experts available now in Live!

Get 1:1 Help Now