Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Checking for NULL in OnUpdateData handler


How can I tell if a user has changed a string field to null in the OnUpdateData event handler? How can I differentiate between a field that was changed to a null string and a field that was not changed at all.   

    Use the NewValue property on the TField when reading the second record (the one which contains the edits). If the returned variant is empty (or Unassigned) then that field was not modified. Here is some code that demonstrates this:

       var
         NewVal: Variant;
       begin
         NewVal := DataSet.FieldByName('MyStrField').NewValue;
         if VarIsEmpty(NewVal) then
            ShowMessage('Field was not edited')
         else if VarIsNull(NewVal) then
            ShowMessage('Field was blanked out')
         else
            ShowMessage('New Field Value: ' + String(NewVal));
       end;
    
    If you look at the source for the RecError form (in the repository), you will see how it uses this information to display the '' string when showing the reconcile errors. On the server you add record level constraints using the constraints property of your TQuery/TTable or field level constraints using persistent TField objects (either CustomConstraint or ImportedConstraint). If you use field level constraints, they are enforced when data is posted to the field (i.e. when you tab out of a data aware control associated with the field).

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use