+ Reply to Thread
Results 1 to 6 of 6

pop up form within userform to confirm choice

Hybrid View

jpruffle pop up form within userform... 05-11-2009, 05:16 AM
ravinder_tigh Re: pop up form within... 05-11-2009, 05:22 AM
royUK Re: pop up form within... 05-11-2009, 05:31 AM
jpruffle Re: pop up form within... 05-11-2009, 07:25 AM
royUK Re: pop up form within... 05-11-2009, 08:10 AM
jpruffle Re: pop up form within... 05-11-2009, 12:12 PM
  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    pop up form within userform to confirm choice

    Hi,

    I have a button within a userform that clears the form:

    Private Sub CommandButton2_Click()
    'Pop up to double check
         ClearCheck.Show
    'Clear Page One
        Me.Actnumber1.Value = ""
        Me.How1.Value = ""
        Me.Whoact11.Value = ""
        Me.Whoact12.Value = ""
        Me.Whoact13.Value = ""
        Me.Act1Date.Value = ""
        Me.Comp11.Value = ""
        Me.Result11.Value = ""
        
    End Sub
    What I want is when it is clicked the userform ClearCheck is shown that basically asks - Are you sure you wish to continue Yes/No.

    If Yes I want the rest of the above Sub to continue. If No then Stop.

    Can you advise. The ClearCheck code is below:

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub
    
    Private Sub CommandButton2_Click()
    
    End Sub
    Thank you in advance.
    Last edited by jpruffle; 05-11-2009 at 12:13 PM.

  2. #2
    Registered User
    Join Date
    04-22-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: pop up form within userform to confirm choice

    Sub Msgbox_Yes_No()
    Dim Response As Integer
    Response = MsgBox(prompt:="Select 'Yes' or 'No'.", Buttons:=vbYesNo)
    ' if user selects yes, i would like to macro(Yes) to continue running
    If Response = vbYes Then
    Resume
    Else
    ' if the user selects no, exit or whtevr code

    End If
    End Sub
    you could use a message box for this case and that could be even fired from any worksheet or workbook event
    Last edited by ravinder_tigh; 05-11-2009 at 05:26 AM.
    Thanks & Regards
    Ravinder S
    (Ravinder_tigh)

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: pop up form within userform to confirm choice

    As suggested just use a message box
    Option Explicit
    
    Private Sub CommandButton2_Click()
        'Pop up to double check
        Select Case MsgBox("This will clear all ntries from the form. Do you want to do this?", vbOKCancel Or vbQuestion Or vbDefaultButton1, "Continue")
    
            Case vbOK
                'Clear Page One
                With Me
                    .Actnumber1.Value = ""
                    .How1.Value = ""
                    .Whoact11.Value = ""
                    .Whoact12.Value = ""
                    .Whoact13.Value = ""
                    .Act1Date.Value = ""
                    .Comp11.Value = ""
                    .Result11.Value = ""
                    End With
                Case vbCancel
    
            End Select
        End Sub
    This would be simpler
    Option Explicit
    
    Private Sub CommandButton2_Click()
        'Pop up to double check
        Select Case MsgBox("This will clear all ntries from the form. Do you want to do this?", vbOKCancel Or vbQuestion Or vbDefaultButton1, "Continue")
    
            Case vbOK
                'Clear Page One
               Unload Me
               userform1.Show '<- change userform name as necessary
    
            End Select
        End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: pop up form within userform to confirm choice

    Thank you both for your suggestions.

    Roy I like your idea of clearing the form without referencing. But two things: Firstly my form is a multipage form and I would like the ability for the button just to clear page1 for example (The button resides on Page1). Secondly is there a way to omit two of the items from being cleared:

    ComboBox - SelectAct1
    and a textbox - ActNumber1?

    Thanks in advance.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: pop up form within userform to confirm choice

    You can't use the second method, this would reset all textboxes, etc

  6. #6
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: pop up form within userform to confirm choice

    Thank you for your advice.

+ 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