Re: If and else in form
In looking at your PDF, I would guess that Montant field does NOT exist (displayed/hidden) on the edit form and you want this Montant value updated in the table (detail grid) after save with the value of either PrixResident / PrixNonResident based on the value of Ville(city) that is brought into the form?
Master form:
if montant fielddoes not exist on master form, then create a var using
$calc_montant or global: [calc_montant]
; call it want you want …
{montant}/$calc_montant = ({ville} == 'city_resident') ? {PrixResident} : {PrixNonResident};
OnAfterUpdate: (master form)
$sql = 'UPDATE services SET montant =' .{montant}.' WHERE servicesID = '.{servicesID};
or
$sql = 'UPDATE services SET montant =' .$calc_montant.' WHERE servicesID = '.{servicesID};
sc_exec_sql($sql);
This will update the child table with the value decided on in the master form. You have to use SQL to update a child table.
If you also need to populate the form with the value based on the IF statement, then onLoad:
{montant} = ({ville} == 'city_resident') ? {PrixResident} : {PrixNonResident};
Then use the above to SQL option to update the table of the displayed value (montant) … where the calculation is created on form load instead of calculating it at the time of save.
If I missed the ball, please explain it to me in more detail.
Regards,
Scott.