locking and unlocking the report filed based on other field (1 Viewer)

rainbows

Registered User.
Local time
Yesterday, 16:29
Joined
Apr 21, 2017
Messages
425
i have a problem where users are ticking the report box even when the have nothing to report of which i am trying to stop
what the report should show is a number !1! in any of the 6 fields along side the report tick box field .
so if possible the report field should be locked until a number higher than zero is entered is entered into one on more of the other 6 fields when an number is entered then they can tick the report box . if they then remove the number and none of the 6 feilds have a number in higher then 0 the report tick box will send a message saying the tick must be removed. lines 1 and 2 is ok but line 3 has a tick in it but i am trying to stop that hope this make sense thanks steve


1655198285524.png
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:29
Joined
Feb 19, 2013
Messages
16,610
checkboxes do not have conditional formatting so you can't disable them, but textboxes do

So suggest swap your checkbox for a textbox that looks like a checkbox, then you can use conditional formatting to disable the control when the values are all zero. Here's how to create your textbox

you will need some additional code to reset the textbox to false in the event it is ticked and the user then resets value to zero. Something like

txtCheck=(txtCheck=true) and (me.machinecapacity+me.equiment+.....<>0)

tested in the immediate window
?true and (1<>0)
True
?true and (0<>0)
False
?false and (1<>0)
False
?false and (0<>0)
False

I presume users are prevented from applying negative values
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:29
Joined
May 7, 2009
Messages
19,229
add code to the Report Checkbox BeforeUpdate Event:
Code:
Private Sub Report_BeforeUpdate(Cancel As Integer)
Cancel = ((Nz([machine capacity], 0) + Nz([equipment], 0) + Nz([manpower], 0)) = 0) + Nz([machine failure], 0)) = 0) + Nz([raw material], 0) + Nz([document], 0)) = 0)
End Sub
 

rainbows

Registered User.
Local time
Yesterday, 16:29
Joined
Apr 21, 2017
Messages
425
thank you both , i have tried this one but got this error

steve

1655201225048.png
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:29
Joined
Feb 19, 2013
Messages
16,610
suggest look at the brackets.

Note that arnel's solution will not reset the checkbox in the event the user ticks it then changes the values to 0 you will still need the additional code per my suggestion to reset it - suggest the form before update event would be a good place
 

Users who are viewing this thread

Top Bottom