Solved

Modal Window Response

Posted on 2011-02-19
12
347 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
 

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

919 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

19 Experts available now in Live!

Get 1:1 Help Now