Reputation: 75
I want to create condition that check other table field in same datasource before modify/update table data.
For example I have table student, field in that table is "status", "name" and "score". Status is enum type and default is "not allow". User can change status field using data grid form.
I want to create condition that Status can change to "allow" if score > 50 else it can't be change. Thanks
Upvotes: 0
Views: 104
Reputation: 5107
As Jan already wrote, one way to solve this would be to overwrite the validateField
method of your student table. This method is called every time a field of the table is changed by the user in the form of the table. In the method you could write some code to handle changes to the Status
field like e.g.
public boolean validateField(FieldId _fieldId)
{
boolean ret;
ret = super();
switch (_fieldId)
{
case fieldNum(MyStudentTable, Status):
if (this.Status == MyStatus::Allow
&& this.Score <= 50)
{
ret = checkFailed("Score must be greater than 50 to Change the Status."); // TODO create a label
}
break;
}
return ret;
}
Upvotes: 0
Reputation: 18051
What about using validation?
Using validateField or validateWrite on the table or datasource you can test whether the chosen value is valid.
Also the validate method on the datasource or control could be used.
Search the Tables or Forms node of the AOT for thousands of examples.
This answer applies to most "check the value of an entered field".
Upvotes: 0