Solved

Modal Window Response

Posted on 2011-02-19
12
351 Views
Last Modified: 2012-08-14
Is there a way to act on the response from a model window? I want to fire a subroutine if the repsonse is 'OK' and bypass one it is 'Cancel.
0
Comment
Question by:ChuckRush
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 6

Expert Comment

by:AkAlan
ID: 34933615
The vbYesNo option can be changed, just type and intellisense will give you the options

Dim confirm As VbMsgBoxResult
  confirm = MsgBox("Are you sure you want to do that?", vbYesNo, "Message goes here")
   
        If confirm = 6 Then
         
              'Run Subroutine here        Else
         Else
               'Do something else here
        End If
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34933624
Certainly:



Dim Msg As Long

Msg = MsgBox("Prompt", vbOKCancel, "Title")
If Msg = vbOK Then
    'do something
Else
    'do something else
End If

Open in new window

0
 
LVL 75
ID: 34933679
It's pretty much just one line of code ....

If MsgBox("Prompt", vbOKCancel, "Title") = vbOk Then Call YourFunctionName ()

mx
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:ChuckRush
ID: 34933738
Ty I understandx thaT but I am wanting to act on the response in the window that called the modal window
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34933756
MX and I show how to do just that.  Where is it that you're getting hung up?
0
 
LVL 75
ID: 34933993
<patrick ... did you end up buying a book?>

mx
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34934026
Yes, I did.  Will update that later :)
0
 
LVL 75
ID: 34934150
Curious to know which book ... stopping by another B&N later today.
Summit ?
0
 
LVL 6

Accepted Solution

by:
Gugro earned 250 total points
ID: 34934275
Usually I use a global var which will get its value from the modal window. e.g.

DoCmd.OpenForm "MyForm", ,,acDialog
if frmRetVal = 'xxx' then ...

where MyForm sets the value in OnClose:

Private Sub OnClose(...)
  frmRetVal = "xxx"
End Sub
0
 

Author Closing Comment

by:ChuckRush
ID: 34934298
Thanks I got to that myself -- sort of had a brain shutdown
0
 
LVL 75
ID: 34934318
ChuckRush
What does that have to do with the MsgBox ?

mx
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34934323
>>Summit ?

Of course :)
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

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…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

685 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