Re: Forms45: Entering/executing query programmatically

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1997/04/11
Message-ID: <5im5ic$ilm_at_info.csufresno.edu>#1/1


In article <334EA490.7366_at_kontron.de>, Wolfgang Pest <wop_at_nodebonn.bmw.de> wrote:
>I have to build masks whose behaviour is different from Forms' default
>behaviour:
>when entering a mask, the user should be immediately entering a query in
>the current block's primary key field. Upon leaving this field, the
>query should be executed. If there exists a record for this primary key,
>it should be displayed and now can be modified (in normal mode). If
>there exists none, he should be able to enter values in those attribute
>fields.
>Now, what triggers can I use to implement this behaviour? Especially,
>where should I call the Execute_Query bultin procedure? The
>When_Validate_Item trigger does not fire in Enter_Query mode and the
>Post_Text_Item trigger does not allow restricted procedures like
>Execute_Query?
>I am new to Forms, so perhaps this is an RTFM question, but I really
>tried to find anything about it in the manual in vain.
>
>Wolfgang Pest
>c/o KONTRON ELEKTRONIK GmbH
>D-85385 Eching
>pestw_at_kontron.de

RTFM? Forget it. You won't find this type of info there. What you are trying isn't very easy.

You would start with a When-Validate-Item (WVI) trigger on the primary key field. You need a hidden primary_key_old_value field as well.

The first thing the WVI trigger should do is compare the key-value to the old-value. You should prevent the user from changing the key-value once the old-value is set.

If the old value is null, then you need to do a query. I would use the value in the key field to
set_block_property('BLK',Default_Where,'key_item='||:Blk.key_item). Then, start a timer that expires immediately. In the When-timer-expired trigger, go_block('BLK'); then Clear_Block(no_validate); then Execute_Query;

After the Execute_Query completes, you will either have a record in the block, or the user can enter new values. If no row was found, you will need to set the key-item (and its old-value) to the value the user entered. If a row was found, set the old-value using a post-query trigger.

Note that nowhere should you do an enter_query. Also, if this is a multi-record block, then it gets more complex, and maybe you should consider another method of querying the data--such as using a control block to enter the key item, and requiring the user to press the execute-query key but running your own key-exeqry process.

Good luck. If you get this working, you won't be so new to Forms anymore.

Steve Cosner



Try out QA, a dynamic data utility form. Quick display and update access to any table. http://members.aol.com/stevec5088 Received on Fri Apr 11 1997 - 00:00:00 CEST

Original text of this message