Re: Couple of questions about Forms 4.5

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1997/04/22
Message-ID: <5jil41$lvo_at_info.csufresno.edu>#1/1


In article <335C80AB.7140_at_entcf3.agw.co.bt.uk>, Alex Heney <heneya_at_entcf3.agw.co.bt.uk> wrote:
>Alan Campbell wrote:
>> I would like to be able to display a date in a different format
>> from the date that is entered in a field. E.g. I have a date field
>> that I would like to display in dd-mmm-yy format, but the users
>> would like to type in the date in ddmmyy format for speed. Is this
>> possible ?
>>
>
> No. The only possible way is to have the screen field defined as
> Character, then manually check the format in code. This is not fun.

It is too fun! ;-) Your actual base-table date field should be hidden, and you display the date in your text field in a post-query trigger, and update your base-table date from the when-validate-item trigger on the text date field.

>> Also how can I jump to another field after the validation on fails
>> on a field. E.g.
>
>This cannot be done directly from the WHEN-VALIDATE trigger, as
>navigation is restricted built-ins. One way of doing this is to use
>timers. You set up a timer when the validtaion is failed, to execute
>after 1 millisecond, no repeat. In the timer code, you can do a GO_ITEM,
>or anything else you want (but remember to set some sort of flag to stop
>the WHEN-VALIDATE failing again when the Go_Item executes).
>
>We use the timer method, both for the above purpose, and where we would
>want a WHEN-VALIDATE to fire an Execute_Query.

I use the above method from time to time, but it gets complicated--if validation fails, you need to do these things:

  1. Don't validate your pair until the user leaves BOTH fields. Moving from one to the other should not cause validation errors.
  2. Set both fields to their current values so when-validate-item triggers run when the user finally leaves the pair, even if nothing was changed in the last item.

In the commit processing, you need to check to see if the pair needs validation, (see if your timer is running), and validate the item immediately before processing the commit. This situation can occur when the user changes one of the pair and tries to commit without leaving the pair.

Not an easy process to get to work. :-(

Regards,
Steve Cosner Received on Tue Apr 22 1997 - 00:00:00 CEST

Original text of this message