Results 1 to 10 of 10

Toggle Button Does not Toggle OFF when Clicked

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-19-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    201

    Toggle Button Does not Toggle OFF when Clicked

    I have two option buttons that can be clicked if either criteria is true. However, if it is clicked accidently, it cannot be unclicked. If i click one, the other will unclick, but I can't UN-click both of them at the same time. Do i need to add code or change the button?

    Full File Attached (.zip)

    below is my existing code. I do have one [checkbox] that toggles on and off and I'm wondering if i need to replace the option buttons with check boxes. (?)


    Private Sub ButtonSave_Click()
        Dim NextFreeRow As Long
        Dim Rng As Range
        Dim ws As Worksheet, ws1 As Worksheet
        Dim Answer As String
        Dim x As Long
        Dim oSh As Worksheet
        Dim cel As Range
        Dim lo As ListObject
        Dim loRowNum As Long
    
    
        Set ws = Sheets("YourJobLog")
    
        If Me.CBTravel.ListIndex = 0 And Me.TBNotOnList = "" Then
            MsgBox "Gotta Enter Mileage"
            Me.TBNotOnList.SetFocus
            Exit Sub
        End If
    
    
        With ws
            Set Rng = .ListObjects(1).ListColumns(1).Range
            NextFreeRow = Rng.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False).Row + 1
    
            Set oSh = ws
            Set cel = oSh.Cells(NextFreeRow - 1, 2)
            If cel.ListObject Is Nothing Then
                Exit Sub
            End If
            Set lo = cel.ListObject
            With lo
                loRowNum = cel.Row - .HeaderRowRange.Row
            End With
            With oSh.ListObjects("Table3373839404123234567824")
                x = .ListRows.Count
                If x = loRowNum Then
                    Application.EnableEvents = False
                    ws.Unprotect "admin"
                    .ListRows.Add AlwaysInsert:=True
                    ws.Protect "admin"
                    Application.EnableEvents = True
                End If
            End With
    
            .Cells(NextFreeRow, 2) = CBJobVenue.Text
            .Cells(NextFreeRow, 3) = TBDate.Text
            .Cells(NextFreeRow, 4) = TBStartTime.Text
            .Cells(NextFreeRow, 5) = TBEndingTime.Text
            .Cells(NextFreeRow, 7) = CBInterpreterName.Text
            .Cells(NextFreeRow, 8) = CBLanguage.Text
            .Cells(NextFreeRow, 9) = TBPatientName.Text
            .Cells(NextFreeRow, 10) = CBGender.Text
            .Cells(NextFreeRow, 11) = CBCampus.Text
            .Cells(NextFreeRow, 12) = TBDepartment.Text
            .Cells(NextFreeRow, 13) = CBRoom.Text
            .Cells(NextFreeRow, 14) = CBTravel.Text
            
            If Me.TBNotOnList <> "" Then
    
                On Error Resume Next
                Application.DisplayAlerts = False
    
                Answer = Application.InputBox _
                         (Prompt:="Please Enter a Description" & vbCrLf & "      of your travel", _
                          Title:="Where Did You Travel", Type:=2)
                On Error GoTo 0
                Application.DisplayAlerts = True
    
                If Answer = "" Or Answer = vbNullString Then
                    Exit Sub
                Else
                End If
                .Cells(NextFreeRow, "N") = Answer
                .Cells(NextFreeRow, "P").Value = Me.TBNotOnList.Value
            End If
    
            .Cells(NextFreeRow, 17) = TBFlexTime.Text
            .Cells(NextFreeRow, 18) = TBBonusTime.Text
            .Cells(NextFreeRow, 19) = OptButCancelled.Value
            .Cells(NextFreeRow, 20) = OptButNoShow.Value
            .Cells(NextFreeRow, 21) = TBNotes.Text
            If Me.CheckBox1.Value = True Then
                .Cells(NextFreeRow, 15).Value = 2
            Else
                .Cells(NextFreeRow, 15).Value = 1
            End If
    
        End With
        response = MsgBox("One Job has been successfully entered into your Job Log.  Do you want to enter another Job?", _
                          vbYesNo)
    
        If response = vbYes Then
            CBJobVenue.Text = ""
            TBDate.Text = ""
            TBStartTime.Text = ""
            TBEndingTime.Text = ""
            CBInterpreterName.Text = ""
            CBLanguage.Text = ""
            TBPatientName.Text = ""
            CBGender.Text = ""
            CBCampus.Text = ""
            TBDepartment.Text = ""
            CBRoom.Text = ""
            CBTravel.Text = ""
            TBFlexTime.Text = ""
            TBBonusTime.Text = ""
            OptButCancelled.Value = False
            OptButNoShow.Value = False
            TBNotes.Text = ""
            Me.TBNotOnList.Value = ""
            Me.CheckBox1.Value = False
    
    
            CBJobVenue.SetFocus
    
        Else
            Unload Me
        End If
    
    End Sub
    Last edited by robbfamily; 06-12-2014 at 08:43 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 02-13-2014, 10:55 PM
  2. [SOLVED] Toggle Button
    By SZBELL in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2013, 10:33 AM
  3. Toggle Button
    By aftabn10 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-02-2010, 07:10 AM
  4. Need help using a toggle button
    By tanktata in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-28-2006, 03:01 PM
  5. Toggle Button
    By NavEx in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-22-2006, 09:45 PM

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