Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

Modal Window Response

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
ChuckRush
Asked:
ChuckRush
  • 4
  • 4
  • 2
  • +2
1 Solution
 
AkAlanCommented:
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
 
Patrick MatthewsCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
It's pretty much just one line of code ....

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

mx
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
ChuckRushAuthor Commented:
Ty I understandx thaT but I am wanting to act on the response in the window that called the modal window
0
 
Patrick MatthewsCommented:
MX and I show how to do just that.  Where is it that you're getting hung up?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
<patrick ... did you end up buying a book?>

mx
0
 
Patrick MatthewsCommented:
Yes, I did.  Will update that later :)
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Curious to know which book ... stopping by another B&N later today.
Summit ?
0
 
GugroCommented:
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
 
ChuckRushAuthor Commented:
Thanks I got to that myself -- sort of had a brain shutdown
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
ChuckRush
What does that have to do with the MsgBox ?

mx
0
 
Patrick MatthewsCommented:
>>Summit ?

Of course :)
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now