Solved

Modal Window Response

Posted on 2011-02-19
12
350 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

837 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