Announcement

Collapse
No announcement yet.

Check For Record

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check For Record

    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
    Last edited by mstopkey; 09-11-2013, 10:44 AM.

  • #2
    {dataset} is not referencing to any field. You need to access an array element for this as {dataset[0][0]}. But in fact, if you only need to know if there's some result. Then you must check for eof:

    Code:
    if ({dataset}->EOF)
     {
       all ok
     }
    else
     {
       duplicate!
     }
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment

    Working...
    X