Re: To skip or not to skip a field in SQL*FORMS

From: L. Carl Pedersen <carl.pedersen_at_dartmouth.edu>
Date: Tue, 25 May 1993 01:07:19 GMT
Message-ID: <carl.pedersen-240593204716_at_kip-sn-67.dartmouth.edu>


In article <1993May24.192249.27099_at_macc.wisc.edu>, dly_at_vms.macc.wisc.edu wrote:
>
> This is a SQL*FORMS 3.0 question.
>
> We are running ORACLE 7.0.12, on Sun/UNIX platform.
>
>
> Here is the problem:
> We have data entry screens which have date fields. If there is no date,
> we require the data entry person to put a two char code in to explain
> why there was no date. For example:
>
> Date of Birth: __ __ /__ __ /__ __ code:__ __ Weight: __ __ __ . __
>
> Here is what I want:
> 1) If there is a valid date entered, I want FORMS to skip over the code
> field. If there is no date, I want FORMS to allow the user to enter the
> code.
>
> 2) If the user goes past the code field, to the Weight field and presses
> the KEY-PRVFLD, I want FORMS to go back to the Date of Birth Field,
> bypassing the code field.
>
> By brute force we can define a trigger for the code field:
> ON-NEW-FIELD-INSTANCE and say:
> if :A.DOB is not null then
> next_field;
> end if;
>
> And also another trigger for the Weight field:
> KEY-PRVFLD
> go_field('DOB');
>
> Is there a better way? I tried playing around with SYSTEM.CURRENT_FIELD,
> but I could not find anything elegant. Since we have over 200 places
> where we would like this done, we would like a more general solution
> if possible. Oracle Technical Support was no help.
>
> Thanks,
> Debbie Yoshihara
> University of Wisconsin
> Department of Biostatistics

Are the date fields consistently named in a way that allows identifying them and distinguishing them from other fields? That will help.

The ON-NEW-FIELD-INSTANCE trigger you suggest won't handle the case of moving backwards. I don't think ONFI is of much help here.

More to the point would be a KEY-NXTFLD trigger that skips the code field if the date field is filled in. NEXT_FIELD will fail if the date is not valid, so bail out if FORM_SUCCESS is not true in this trigger.

You could make form-level triggers for KEY-NXTFLD and KEY-PRVFLD. These would use :SYSTEM.TRIGGER_FIELD and FIELD_CHARACTERISTIC to see if the next/previous field is a code or date field and act accordingly. I think this will work only if you use some consistent naming convention for the fields.

Another possibility would be to have an ON-VALIDATE-FIELD trigger, possibly one that fires for all fields, that calls a procedure when it is validating one of your date fields. The procedure would use SET_FIELD to make the corresponding code field enterable and required, if the date is null, or non-enterable if the date is not null. Unfortunately, SET_FIELD can be quite slow, so you may want to test this approach before committing to it.

How air-tight does this have to be? Can users navigate with a mouse? If so, you may also want to have an ON-VALIDATE-RECORD trigger that performs similar checks.

Send me email if any of this is not clear. Received on Tue May 25 1993 - 03:07:19 CEST

Original text of this message