Hello all. I have a problem with check for record then display message if exists. I know it is a simple process but am banging my head against wall to get this one to work. This is a credit card payment entry form. After entering credit card info in a form it redirects to the payments form.
One table with two fields. Fields are ccard_id, datedue, duaamt. datedue field is date stamp.
Single record payments form, action is enter new record and prevent duplicate datedue being entered while entering another payment.
I want to force a check for record where ccard_id = ‘{ccard_id}’ and datedue = ‘SELECTED’ ‘{datedue}’.
If the datedue already exists for a payment on this ccard_id, do not allow the insert and display a message.
This is what I have onValidate event.
$datecheck = sc_lookup(dataset, “SELECT MAX(datedue) FROM ccard_payments WHERE ccard_id = ‘{ccard_id}’”);
$error_test = {dataset} == $datecheck;
$error_message = ‘Payment date due already exists for another payment. Please select a different date due.’;
if ($error_test)
{
sc_error_message($error_message);
}
Many thanks