Solved

Modal Window Response

Posted on 2011-02-19
12
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

751 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