The OldValue Property

If someone changes a value in a field and that change has repercussions for other fields on the form, you may wish to use the OldValue property. Here is a sample and just to explain, CreditRequired is a Yes/No combo box

Private Sub CreditRequired_Click()

  Dim intYesNo As Integer

  If CreditRequired = False And CreditRequired.OldValue = True And Not IsNull(CreditRequestDate) Then

    intYesNo = MsgBox("Choose Y and the Credit details will be cleared", vbYesNo + vbDefaultButton2, "Remove Credit Details")

    If intYesNo = vbYes Then

      CreditRequestDate = Null

      CreditCode = Null

    Else

      'Reset the value back to the previous value and do nothing

      CreditRequired.Value = CreditRequired.OldValue

    End If

  End If

 

About Garry Robinson

He is the guy who originally put this Smart Access web site together. Head to www.gr-fx.com.au for more about him and his company. His main claim to fame is winning the Microsoft MVP award for services to MS Access from 2006 to 2018.
This entry was posted in Forms. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.