Results 1 to 2 of 2

Thread: Toggle Trouble in MultiPage UserForm

  1. #1
    Neophyte DMKean's Avatar
    Join Date
    Jan 2013
    Location
    BC's Northern Capital
    Posts
    1
    Articles
    0

    Toggle Trouble in MultiPage UserForm



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I'm a newbie when it comes to VBA and most of the problems I've had I've been able to figure out with the help of my John Walkenbach book and the internet but this problem eludes me.

    I'm building a Wizard and am using a toggle button to indicate whether or not a procedure has been done. Click the toggle if it's been done (value True), don't click the toggle if it hasn't (value False). Once the user clicks my "Finish" button and transfers the entered data to a spreadsheet, including the toggle selection, the text boxes and the toggle should clear/reset. My text boxes clear, but my toggle doesn't reset. What am I missing?

    My toggle has the following code attached:
    Private Sub toggleYes1_Click()
    Me.toggleYes1 = True
    End Sub

    Following is some of the code attached to my Finish button (this is to clear my text boxes and reset the toggle).
    me.tbDrugName2 = ""
    me.toggleYes1 = FALSE
    me.tbAdditionalNotes2 = ""
    me.tbSize2 = ""
    me.tbAdjustmentQuantity = ""
    me.tbUnitCost = ""

    Any help anyone could provide would be very helpful!

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    the line:
    me.toggleYes1 = FALSE
    is itself triggering the toggleYes1_Click event.

    You could use a global variable thus:
    Code:
    Dim ToggleClickSuppress As Boolean 'the global variable
    
    Private Sub CommandButton1_Click()
    Me.tbDrugName2 = ""
    ToggleClickSuppress = True
    Me.toggleYes1 = False
    ToggleClickSuppress = False
    Me.tbAdditionalNotes2 = ""
    Me.tbSize2 = ""
    Me.tbAdjustmentQuantity = ""
    Me.tbUnitCost = ""
    End Sub
    
    Private Sub toggleYes1_Click()
    If Not ToggleClickSuppress Then Me.toggleYes1 = True
    End Sub

    Last edited by p45cal; 2013-11-28 at 01:21 PM.

Posting Permissions

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