+ Reply to Thread
Results 1 to 6 of 6

Simple message Yes No...

  1. #1
    Registered User
    Join Date
    07-18-2005
    Posts
    1

    Simple message Yes No...

    Below is my attempts at basic VB

    Dim lngUserChoice As Long
    lngUserChoice = MsgBox("Do you want to Undo last entry?", _
    vbYesNo + vbQuestion, "Undo Last Entry")
    If lngUserChoice = vbYes Then
    GoTo Account_undo
    If Response = vbNo Then GoTo Bye
    End If
    End Sub

    I am getting an error message Compile Error: Label Not Defined...I figure this is a basic step I am missing...I am trying to get a message button to go forward with the Macro Account_undo if yes and if no end...don't execute...

    I appreciate your help.

  2. #2
    Tim Williams
    Guest

    Re: Simple message Yes No...

    >> GoTo Account_undo

    You do not have a line label named "Account_undo" in your procedure.

    Tim

    --
    Tim Williams
    Palo Alto, CA


    "jmhadp" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Below is my attempts at basic VB
    >
    > Dim lngUserChoice As Long
    > lngUserChoice = MsgBox("Do you want to Undo last entry?", _
    > vbYesNo + vbQuestion, "Undo Last Entry")
    > If lngUserChoice = vbYes Then
    > GoTo Account_undo
    > If Response = vbNo Then GoTo Bye
    > End If
    > End Sub
    >
    > I am getting an error message Compile Error: Label Not Defined...I
    > figure this is a basic step I am missing...I am trying to get a message
    > button to go forward with the Macro Account_undo if yes and if no
    > end...don't execute...
    >
    > I appreciate your help.
    >
    >
    > --
    > jmhadp
    > ------------------------------------------------------------------------
    > jmhadp's Profile:

    http://www.excelforum.com/member.php...o&userid=25340
    > View this thread: http://www.excelforum.com/showthread...hreadid=388196
    >




  3. #3
    Tim Williams
    Guest

    Re: Simple message Yes No...

    I forgot to add in my previous post - it is considered bad style to use
    "goto" anywhere outside of error-handling routines.

    What are "Account_undo" and "Bye" ? Are they subroutines?

    Tim

    --
    Tim Williams
    Palo Alto, CA


    "jmhadp" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Below is my attempts at basic VB
    >
    > Dim lngUserChoice As Long
    > lngUserChoice = MsgBox("Do you want to Undo last entry?", _
    > vbYesNo + vbQuestion, "Undo Last Entry")
    > If lngUserChoice = vbYes Then
    > GoTo Account_undo
    > If Response = vbNo Then GoTo Bye
    > End If
    > End Sub
    >
    > I am getting an error message Compile Error: Label Not Defined...I
    > figure this is a basic step I am missing...I am trying to get a message
    > button to go forward with the Macro Account_undo if yes and if no
    > end...don't execute...
    >
    > I appreciate your help.
    >
    >
    > --
    > jmhadp
    > ------------------------------------------------------------------------
    > jmhadp's Profile:

    http://www.excelforum.com/member.php...o&userid=25340
    > View this thread: http://www.excelforum.com/showthread...hreadid=388196
    >




  4. #4
    Norman Jones
    Guest

    Re: Simple message Yes No...

    Hi Jmhadp,

    Try the following revision:

    Sub Tester05()
    Dim Res As Long
    Res = MsgBox("Do you want to Undo last entry?", _
    Buttons:=vbYesNo + vbQuestion, _
    Title:="Undo Last Entry")

    If Res = vbYes Then Call Account_Undo

    End Sub

    Public Sub Account_Undo()
    'Your Undo steps
    MsgBox "Hi from Account_Undo!"
    End Sub

    ---
    Regards,
    Norman



    "jmhadp" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Below is my attempts at basic VB
    >
    > Dim lngUserChoice As Long
    > lngUserChoice = MsgBox("Do you want to Undo last entry?", _
    > vbYesNo + vbQuestion, "Undo Last Entry")
    > If lngUserChoice = vbYes Then
    > GoTo Account_undo
    > If Response = vbNo Then GoTo Bye
    > End If
    > End Sub
    >
    > I am getting an error message Compile Error: Label Not Defined...I
    > figure this is a basic step I am missing...I am trying to get a message
    > button to go forward with the Macro Account_undo if yes and if no
    > end...don't execute...
    >
    > I appreciate your help.
    >
    >
    > --
    > jmhadp
    > ------------------------------------------------------------------------
    > jmhadp's Profile:
    > http://www.excelforum.com/member.php...o&userid=25340
    > View this thread: http://www.excelforum.com/showthread...hreadid=388196
    >




  5. #5
    ElectroAeroguy
    Guest

    Re: Simple message Yes No...

    Nor one named "Bye" for that matter ...

    "Tim Williams" wrote:

    > >> GoTo Account_undo

    >
    > You do not have a line label named "Account_undo" in your procedure.
    >
    > Tim
    >
    > --
    > Tim Williams
    > Palo Alto, CA
    >
    >
    > "jmhadp" <[email protected]> wrote in
    > message news:[email protected]...
    > >
    > > Below is my attempts at basic VB
    > >
    > > Dim lngUserChoice As Long
    > > lngUserChoice = MsgBox("Do you want to Undo last entry?", _
    > > vbYesNo + vbQuestion, "Undo Last Entry")
    > > If lngUserChoice = vbYes Then
    > > GoTo Account_undo
    > > If Response = vbNo Then GoTo Bye
    > > End If
    > > End Sub
    > >
    > > I am getting an error message Compile Error: Label Not Defined...I
    > > figure this is a basic step I am missing...I am trying to get a message
    > > button to go forward with the Macro Account_undo if yes and if no
    > > end...don't execute...
    > >
    > > I appreciate your help.
    > >
    > >
    > > --
    > > jmhadp
    > > ------------------------------------------------------------------------
    > > jmhadp's Profile:

    > http://www.excelforum.com/member.php...o&userid=25340
    > > View this thread: http://www.excelforum.com/showthread...hreadid=388196
    > >

    >
    >
    >


  6. #6
    Jim Thomlinson
    Guest

    RE: Simple message Yes No...

    You have a couple of small problems here. You are using gotos when they
    really are not appropriate (other than error handling they never are). Also
    you have 2 if statements and only one end if. It should look more like this...

    public sub Whatever

    if msgbox("Do you want to undo the last entry?", vbYesNo, _
    "Undo Entry") = vbYes Then
    Call Account_Undo
    else
    Call Bye
    end if
    end sub
    --
    HTH...

    Jim Thomlinson


    "jmhadp" wrote:

    >
    > Below is my attempts at basic VB
    >
    > Dim lngUserChoice As Long
    > lngUserChoice = MsgBox("Do you want to Undo last entry?", _
    > vbYesNo + vbQuestion, "Undo Last Entry")
    > If lngUserChoice = vbYes Then
    > GoTo Account_undo
    > If Response = vbNo Then GoTo Bye
    > End If
    > End Sub
    >
    > I am getting an error message Compile Error: Label Not Defined...I
    > figure this is a basic step I am missing...I am trying to get a message
    > button to go forward with the Macro Account_undo if yes and if no
    > end...don't execute...
    >
    > I appreciate your help.
    >
    >
    > --
    > jmhadp
    > ------------------------------------------------------------------------
    > jmhadp's Profile: http://www.excelforum.com/member.php...o&userid=25340
    > View this thread: http://www.excelforum.com/showthread...hreadid=388196
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1