Solved

vbYes and vbNo, either way not working

Posted on 2014-12-23
4
207 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

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
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 34

Accepted Solution

by:
PatHartman earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
AHHH....I gotcha
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

763 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

10 Experts available now in Live!

Get 1:1 Help Now