Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Values before editing and after saving
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01286843
Message ID:
01286861
Views:
19
This is a multi-user environment with a local table.
The following is my SaveIt() routine:
LOCAL llGoodSave
WITH ThisForm
   REPLACE scrap.lastupdate WITH DATE()
   REPLACE scrap.upDatedBy  WITH oApp.cUserName
   llGoodSave = TABLEUPDATE(0,.T., .cTable)
   IF !llGoodSave
      WAIT WINDOW NOWAIT "Was not able to save changes."
   ELSE
      .newButton.Enabled = .T.	&& Turn New button back on now that
                                && data has been saved.
      .reportButton.Enabled = .T. && Turn REPORT button back on,...
      .saveButton.Enabled = .F.		
      .cancelButton.Enabled = .F.
      WAIT WINDOW NOWAIT "Save was successful!"
   ENDIF
ENDWITH
RETURN llGoodSave
I also have an IsChanged() Method:
* The GetFldState tells us if a change has been made to the entire record (-1).
LOCAL lcFieldState, llRecordChanged
WITH ThisForm
   lcFieldState = GetFldState(-1, .cTable) && Get the field state of the
                                           && entire record.
   IF !IsNull(lcFieldState)
      llRecordChanged = '2' $ lcFieldState OR ;
         '3' $ lcFieldState OR '4' $ lcFieldState
   ELSE
      * GetFldState may return a null value, so compensate for this.
      * It should return a string, usually.
      llRecordChanged = .F.
   ENDIF
ENDWITH

RETURN llRecordChanged
*-- Buffering must be on
CURSORSETPROP ("Buffering", 5, "MyTable")

DO CASE
CASE GETFLDSTATE ("MyField") = 1
    *-- Field has not been modified or deletion status has not changed
CASE GETFLDSTATE ("MyField") = 2
    *-- Field has been modified or deletion status has changed
    lcOldVal = OLDVAL ("MyField", "MyTable")
    lcNewVal = MyTable.MyField
CASE GETFLDSTATE ("MyField") = 3
    *-- Field in an appended record has not been modified or deletion status has not changed for the appended record
CASE GETFLDSTATE ("MyField") = 4
    *-- Field in an appended record has been modified or deletion status
    *-- has changed for the appended record
ENDCASE
>In a multi-user environment, you may use CURVAL () instead of OLDVAL ().

>>I need to check to see if a value has changed on a form and if it has, record this by placing the before and after values into a memo field in the same table, along with the User's name and date/time the change was made; is there a simple way to do this?
Previous
Reply
Map
View

Click here to load this message in the networking platform