Re: Forms 4.5: Validating a multi-record block prior to commit time

From: <stevec_at_zimmer.csufresno.edu>
Date: Wed, 27 May 1998 15:19:16 GMT
Message-ID: <6khatk$cup$1_at_nnrp1.dejanews.com>


In article <01bd8828$d2569180$764c1bcc_at_toddo.gcr1.com>,   "Todd Owers" <ToddO_at_gcr1.com> wrote:
>
>
> I have a multi-record block that has 2 validation requirements:
>
> 1) no duplicate entries
> 2) an entry of "None" is mutually exclusive with any other entry. In
> other words, if "None" is entered, it must be the only entry.
>
> If either of these conditions is violated, I want to display an alert prior
> to commit time, but I can't figure out how to do it. I know how to test
> for duplicate entries by using a When-Validate-Item trigger to compare the
> current item to values fetched from the database, but that is not what I
> want to do here. I want to compare the items to each other, not to the
> database.
>
> There must be a way to do this. I was thinking about using a non-query
> record group. In a When-Validate-Record trigger, I would add each record
> to the group, so the contents of the block and the record group would be
> identical. As each record is added to the record group, I would loop
> through the existing records and perform the two tests.
>
> Does this sound like the best way to accomplish what I want? Or is there a
> quicker, more efficient way to do this?

Using a record group to echo what is in the block is the most difficult way to do that. The difficulty comes in making sure your record group echos what is in the block after the user inserts or deletes rows. (Updates are easyier.)

I think the easiest way is to post each row to the database after the user makes an entry, then use a select against the database to see if there are any duplicates or a "none". The tough part on this one is that you have to issue a rollback if the user decides not to commit, to make sure the posted but uncommitted records get backed out of the database. I have not tried this method, but I have seen others suggest it.

The method I use involves editing with a timer. In your when-validate-item trigger (or when-validate-record if necessary), if the user has made a new entry, start a timer that lasts 1 millisecond, and store the current record value so you know which record was entered.

When the timer expires, store the location of the cursor (in case user clicked into another block), and go_block back to the one to be edited. Do a first_record, then loop through all the records in the block looking for the error condition. If none is found, put the cursor back on the row and block you originally stored. If an error is found, go to the record that the user just entered, and issue an error message. If you have a scrolling block, you may need to use top_record and some additional work to get the block to display the way it was before you started looping through the rows.

Hope this helps.
Steve Cosner



http://members.aol.com/stevec5088
Downloadable Quick Access utility form: Display and update any table.

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Wed May 27 1998 - 17:19:16 CEST

Original text of this message