Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

vbYes and vbNo, either way not working

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
Ernest Grogg
Asked:
Ernest Grogg
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
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
 
PatHartmanCommented:
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
 
HainKurtSr. System AnalystCommented:
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
 
Ernest GroggAuthor Commented:
AHHH....I gotcha
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now