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.
ChuckRushAsked:
Who is Participating?
 
GugroConnect With a Mentor Commented:
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
 
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
It's pretty much just one line of code ....

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

mx
0
 
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 Access MVP)Database ArchitectCommented:
<patrick ... did you end up buying a book?>

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

mx
0
 
Patrick MatthewsCommented:
>>Summit ?

Of course :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.