![]() |
![]() |
|
![]() |
Subject: FAQ:PdoxWin:Trapping when a record has changed: 1999.12.21 Version 1.0 (1999.12.21) edited by Paradox FAQ Team Repost by Mike Irwin: 2001.02.05 Repost by Mike Irwin: 2001.05.25 ==================== 0. Introduction ==================== This FAQ addresses a common request: "how do I trap for a changed record, in order to do something ?". The reason for wanting to trap this situation is most commonly: a. to check for acceptable values in the altered record b. to add a "last changed" value to a timestamp field This FAQ is appropriate to users of all versions of Paradox for Windows ------------------------------- 0.1 Legal Info and Disclaimers ------------------------------- Paradox is a trademark of Corel. Borland Database Engine (BDE) is a trademark of Inprise. The information provided in this FAQ is provided "as is" and is not warranted in any way. The information provided in this FAQ is not endorsed or authorized by Corel or Inprise in any shape, form, or manner. The editors claim NO responsibility for ANY illegal activity regarding this file, or as a result of someone reading this file. You may distribute this file, as long as the copies are complete, unaltered, and are in electronic form only. ------------- 0.2 Feedback ------------- Please send feedback in a Corel Paradox newsgroup or the news:comp.databases.Paradox newsgroup to any of the FAQ Team mentioned in the "FAQ: FAQ FAQ" document. Please preface the subject of your post with the string "PDXWIN FAQ" to alert Team members to the function of the message. Please specify the FAQ name and section number the comment applies to, if any. ============================== 1. General Information ============================== As stated above, this situation occurs when the programmer wishes to do something as a result of the user wishing to post a record. It may be that some data validation is needed; it may equally be that some sort of audit trail must be established; or it may simply be that some extra information (such as a timestamp) must be added to the record. ============================== 2. Suggested Technique ============================== The following code should be placed in the action() method of either the Form, or of the structure (tableFrame or MultiRecord Object). If it is placed at the form level (as shown in the example below) , it should be placed in the "else" part of the code added automatically to the method, and you may need to check that the events are coming from the correct object. var siId smallInt endvar if eventInfo.isPreFilter() then else siId = eventinfo.id() if siId = DataPostRecord or (siId = DataUnlockRecord and active.RecordStatus("Modified") ) then disableDefault ;suspend posting ... ;Resulting Code (see below) doDefault ;complete the post ... endif endIf This code might be used when checking whether a record is valid if <some required condition fails> then eventInfo.setErrorCode(peCannotDepart) endif This code might be used to add a timestamp to a record dmPut(active.tablename,"LastEdit",Today()) One of the most common ways of preventing a bad update is just to use disableDefault and never post the record. However, this can have other consequences, so it is recommended that if your code decides that a record should not be posted, you should set an appropriate error code and allow Paradox to complete processing as it wishes. In this way the programmer achieves the desired effect with minimal effect on the system. The error code used, peCannotDepart, may not be the only one to work correctly; however, it is the one most often used when this action() is triggered by a depart() attempt from a record. Paradox Community Newsgroups |
![]() Feedback | Paradox Day | Who Uses Paradox | I Use Paradox | Downloads ![]() |
|
![]() The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation. Paradox is a registered trademark of Corel Corporation. ![]() |
|
![]() Modified: 15 May 2003 Terms of Use / Legal Disclaimer ![]() |
![]() Copyright © 2001- 2003 Paradox Community. All rights reserved. Company and product names are trademarks or registered trademarks of their respective companies. Authors hold the copyrights to their own works. Please contact the author of any article for details. ![]() |
![]() |
|