Annoying AfterUpdate/Exit Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Coolboy55
    New Member
    • Jul 2007
    • 67

    #1

    Annoying AfterUpdate/Exit Problem

    When the value of a field is changed, I'm passing the new value into a history table along with a date stamp. Since the old value is not updated until the Exit event, I can't use the AfterUpdate event to pass the new value to the history table. Of course, the problem is that every time I exit the field, whether I change it or not, it wants to write the value to the history table.

    I want to write the new value to the history table only when the value changes, not on every Exit event.

    How can I get the functionality I'm looking for? There must be a way...

    Thanks!
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Can you not use the beforeUpdate of the form itself? That way changes will only be stored when the record is ready to be saved.

    Comment

    • Coolboy55
      New Member
      • Jul 2007
      • 67

      #3
      Thanks for your response. Essentially I am keeping a price change history, and I only want the record to be written to the price history table when the price is modified. The field value has not updated yet when the BeforeUpdate form event runs. If I use the AfterUpdate form event, the value is updated, but I can't compare the current Field.Value with the Field.OldValue to see if they are different since the old value has already been updated too. :(

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Originally posted by CoolBoy55
        CoolBoy55:
        Since the old value is not updated until the Exit event
        I'm really not with you on this. This value is maintained until the record buffer is saved away, usually by moving to another record.

        I suspect you should create the (pending) data in the AfterUpdate event of the control, then in the AfterUpdate event of the form, you can check to see if there is anything pending and write it to history then.

        Comment

        • Coolboy55
          New Member
          • Jul 2007
          • 67

          #5
          Great, that pointed me to the solution. At first it wasn't working because my append query had a problem: it was pulling data from the table (which is not updated until after the AfterUpdate event) rather than from the form control, which is already updated to the new value. Problem solved. Thanks!

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            I'm glad that helped. Sorry for the delayed response. I was away all last week.

            Comment

            Working...