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
Bookmarks