keep users from "unchecking" checkbox

lscheer

Registered User.
Local time
Today, 15:01
Joined
Jan 20, 2000
Messages
185
This seems like a simple procedure, but I'm not sure how to go about it. I have a series of checkboxes (most of which are independent of one another), and I want to prevent users from unchecking a checkbox that has already been checked. I do not simply want to prevent null values because the default value is null.

Thanks!
 
You will need to add code to two places:

First on the checkboxes After Update Event:

If Me.CheckboxName = True Then
Me.CheckboxName.Enabled = False
Else
End if

Second in the On Current Event of the Form:

Dim ctl As Control
Dim frm As Form
Set frm = [Forms]![FormName]

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acCheckBox
if me.ctl = True then
me.ctl.enabled = False
Else
me.ctl.enabled = True
End Select
Next ctl

HTH
 
I see a couple of problems with jfgambit's solution.

One, I don't think Access will let you disable a control while it still has focus (which I think it does at the After Update stage). I tried his code and got an error message to that effect.

Two, and more importantly, if you COULD disable it at this stage, the user could not correct the situation if he/she accidentally checked the box. The user should be able to correct a mistaken check at least until they leave the record.

And three (I know, I said there were two problems, so sue me) if a user checks the box, leaves the record, and realizes his mistake, then you have a problem that the system administrator will probably have to solve. The correction would have to be made directly into the table.

The Missinglinq
 
Missing:

True...you would need to Set the focus to another area before the save...

As for the "problem" with not changing back...

I was answering the original statement:

I want to prevent users from unchecking a checkbox that has already been checked

I made assumptions as to the situation the db was in...in the future I'm sure a more detailed decription of the problem would be appreiated.
 
Well, we all know about assumptions, but enough said. I was really pointing out to lscheer some things he needed to think about, based on his original statement.

What I'm really curious about...what exactly is a "Kinetic card dealer ?"

The Missinglinq
 
Thanks for the input from both missinglinq and jfgambit. gambits code looks like it will help immensely and missing's points are well-taken. I will only be using this code for certain checkboxes under which situation if the user mistakenly checks the box I (the db administrator) would have to intervene anyhow (the code behind them currently adds a record to another table).

Thanks everyone!
-Lydia
 

Users who are viewing this thread

Back
Top Bottom