Solved

vbYes and vbNo, either way not working

Posted on 2014-12-23
4
238 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
[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 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 37

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 53

Expert Comment

by:Huseyin KAHRAMAN
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

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!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

710 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