Solved

vbYes and vbNo, either way not working

Posted on 2014-12-23
4
221 Views
Last Modified: 2014-12-23
hello,

I am having another rough day.

I have this code and can't seem to get it to work...whether you push yes or no it returns to the form and does nothing...

If Me.Dirty Then
    MsgBox "You must either finish the record or cancel the record, Do you want to cancel this record?", vbYesNo
    If response = vbYes Then
        Me.Undo
        DoCmd.OpenForm "frmLicense"
        Else
            If response = vbNo Then
                Exit Sub
            End If
    End If
Else
DoCmd.OpenForm "frmLicense"
End If

what am I missing?
0
Comment
Question by:Ernest Grogg
4 Comments
 
LVL 57
ID: 40515495
You have to do:

 If MsgBox( "You must either finish the record or cancel the record, Do you want to cancel this record?", vbYesNo) = vbYes Then

or

Dim intRet as integer

intRet = MsgBox ("You must either finish the record or cancel the record, Do you want to cancel this record?", vbYesNo)

If intRet = vbYes Then

Jim.
0
 
LVL 35

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40515496
Response is an argument in some form/control events.  It is not an argument of MsgBox.  Enclose the arguments to Msgbox in parentheses so you can capture the response directly.
If Me.Dirty Then
     If MsgBox("You must either finish the record or cancel the record, Do you want to cancel this record?", vbYesNo) =  vbYes Then
          Me.Undo
         DoCmd.OpenForm "frmLicense"
    Else
       Exit Sub
   End If

Open in new window

0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40515499
MsgBox "You must either finish the record or cancel the record, Do you want to cancel this record?", vbYesNo
>>>
response = MsgBox "You must either finish the record or cancel the record, Do you want to cancel this record?", vbYesNo
0
 

Author Closing Comment

by:Ernest Grogg
ID: 40515509
AHHH....I gotcha
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access: Adding Reference for Dymo 450 Labelwriter SDK 6 16
Access report groups with sums 5 24
Combobox row source 2 19
backup programme - VBA 3 22
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now