1
votes

I have a checkbox in the DataWindow, It can be checked and unchecked. The default value in the db is 0. When it's checked, the db value is updated to 1 and on uncheck, the value is updated to 0 again.

However, I want to update the database only if it has value 0. If it is already 1, then I don't want the user to be able to change it back to 0. So please tell me how can I do that? Here is the code from my DataWindow for the checkbox column:

column=(type=decimal(0)  update=yes updatewhereclause=yes name=ok dbname="table.ok"  values="1/0"  )
2

2 Answers

2
votes

You could protect the checkbox to prevent unchecking it : in the general / protect field of your checkbox :

if(ok = 1, 1, 0)

Once the checkbox has been checked, it becomes protected (you still have to update the data to the base). On the next retrieve, you can see that the checkbox is already protected.

You might have to use a similar expression for the Pointer to show that the field is blocked, for example with the NoPointer! cursor.

0
votes

try using: if( upper(ok) = 'OFF', 1, 0) or the other way around: if(upper(ok) = 'ON', 1, 0) depending on how you set the on/off values in the properties of the check box.

Note I'm using PowerBuilder 2017