I'd like to make a field required on a subform. I've tried two methods:
1) Set the Restriction on the field to !. This works sometimes, but it can be bypassed. For example, it works when you try to navigate to different sub-record, but it fails to be enforced when you save the main form.
2) Programatically check the field in the subform's Form Exit event (code example below). This leads to an infinite loop within Sesame that can I can only kill via the Windows Task Manager.
NotifyForm(1)
If @IsBlank( txtField ) Then
@Msgbox( "The field must be populated.", "", "" )
Else
NotifyForm(-1)
So where should subform validation occur?
EDIT: Maybe this question belongs on another thread, but related to the above, I'd like to use the FormDependentValue to recalculate my subrecord totals automatically. However, that function appears to force a commit of the current subrecord, which I don't want to have happen if validation fails. I'd like to add automatic re-totaling, but when I tried to add it by looping through the subrecord result set on the parent form's Change event, I couldn't add new sub-records programatically (as the loop would eliminate the uncommitted subrecord which I programatically created using @FormNewRecord).