ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkbox Lock (https://www.excelbanter.com/excel-programming/320447-checkbox-lock.html)

Leanne

Checkbox Lock
 
I am a new programmer in excel. I need lock the checkbox after checkbox
checked. I tried use property locked, enabled no one works. I used click
event. Need help. Thanks.





Dave Peterson[_5_]

Checkbox Lock
 
Maybe you could just disable it from future use:

Option Explicit
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Me.CheckBox1.Enabled = False
End If
End Sub



Leanne wrote:

I am a new programmer in excel. I need lock the checkbox after checkbox
checked. I tried use property locked, enabled no one works. I used click
event. Need help. Thanks.


--

Dave Peterson

Dave Peterson[_5_]

Checkbox Lock
 
But I'd hate to see that (as a user). I often click on the wrong checkbox and
have to correct it.

Leanne wrote:

I am a new programmer in excel. I need lock the checkbox after checkbox
checked. I tried use property locked, enabled no one works. I used click
event. Need help. Thanks.


--

Dave Peterson

Norman Jones

Checkbox Lock
 
Hi Leanne,

Adapting Dave's code to acknowledge his warning, perhaps try:

Private Sub CheckBox1_Click()
Dim res As Long
If Me.CheckBox1.Value = True Then
res = MsgBox("Are you sure you meant to " & _
"check this option?", vbYesNo, "Please Confirm")
If res = vbYes Then
Me.CheckBox1.Enabled = False
Else
Me.CheckBox1.Value = False
End If
End If

End Sub

This throws up a message box if the user checks the box and asks for
confirmation. Annoying, if the box was intentionally checked, but less
annoying, perhaps, than being unable to undo an unintentional click.

---
Regards,
Norman



"Leanne" wrote in message
...
I am a new programmer in excel. I need lock the checkbox after checkbox
checked. I tried use property locked, enabled no one works. I used click
event. Need help. Thanks.








All times are GMT +1. The time now is 04:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com