disable a checkbox after update

dai@wellgone.co

New member
Local time
Today, 05:50
Joined
Feb 10, 2005
Messages
6
Hi I have a simple check box that if ticked puts a big red Cancellation text across the record, how do I stop anybody unchecking it on the particular record...probably dead simple, tried loads of combinations but I can't get the right code,thanking you in advance
Dave Williams
Sunny Lanzarote in The Canary Islands
 
On the OnCurrent event, which fires for each new record, do your test and if valid then lock the checkbox, otherwise unlock it.


Private Sub Form_Current()
if (your test) then
me!chkYour.locked = true
else
me!chkYour.locked = false
End Sub
 
I am still doing something wrong, I have tried a variety of combos again, am getting a runtime error 438 Object doent support this property or method

Private Sub Form_Current()
If ([CX] < 0) Then
Me![CX].Locked = True
Else
Me![CX].Locked = False
End If
End Sub

thx Dave
 
What is "[CX]"? What is that supposed to reference?

I think that "If ([CX] < 0) Then" might be bad code. User the debugger on that code to see where the error is generated.
 
IF CX is a checkbox, it can have two values, true or false.

If you have two check boxes, why are they named the same way?
 
I have 1 checkbox control named CX, the form is Amend Res, the checkbox is set to return -1 if true. the code for the cancellation message is thus
=IIf([CX]<0,"CANX") which works but is a contol for a textbox...by the way thx for your input 1.35 am here
 
A checkbox can have three values, Null, True, & False.


=IIf([CX]<0,"CANX")

is not a valid instruction.

What are you trying toi accomplish by placing brackets around CX, it adds nothing. Presumably, you me form control CX.

=iif(Me.CX,then,else) is the proper format.

A checkbox can always be tested against True, but not necessarily False, because it could be Null, i.e. not initialized or set.

If me!CX then

or

If me!CX=True then

or

if not me!CX then

are all correct.

But

if me!CX = False then ' won't necessarily work because of the Null value.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom