Home  Fees/Services  Microsoft Access Templates  Tutorials  Tutorial Download  Articles  Search  Contact  Privacy  Links
Old Value New Value Visual Basic Access Visual Basic - VBA Macros
Old Value New Value Visual Basic
Save Field Values Before Update
 





Visual Basic Tutorials:
Access-Google Earth
Age Calculation
Change To Proper Case
Email via Gmail
Outlook Email
Read Email Access
Email Attachment
Send Outlook Email
Running Sum
Concatenate Records
Stock Quotes
CreateQueryDef
Find Database Path
Detail-Master Update
Data Validation
Field Value New-Old
FindFirst
Access Version
Global Variable Parameter
Global Variables
Active Labels
Files List Box
Mail Merge
Quick Sort
Recordset Filters
Reference Form Field
Select Case
Access Transactions


Visual Basic Function Examples


Current Value vs. Previous Field Value

Compare original value of field to new value of field in the
after update event

Ever wonder why it is so difficult to figure out what the original value of a form field was after the user updates the field? I thought that the Before Update event would help me do this but using the Me.Fieldname.Oldvalue doesn't give me the old value it gives the new value!

Here is a simple way to do this:  First set up a global variable in this form just after the Option Compare Database.  In this example we dimension a string variable called hold_value.

Option Compare Database
   Dim hold_value As String
    ...

Next we create an On Current event for the form:

Private Sub Form_Current()
    hold_value = Me.icount
End Sub

You may find that you get a null value error so you might want to use the following assignment to get around this little problem:

hold_value = Nz(Me.icount, "")
' those are two double quote marks together

Finally in the After Update event we have both the new and old values available for us to use:

Private Sub icount_AfterUpdate()
    MsgBox hold_value & " " & Me.icount
End Sub

It may also be useful to use this technique in the Before Update event... in case you want to do some validation checking before the value is saved to the database.








Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013


Blue Claw Database Design Downloadable Tutorial:
Sequential Counter in Query  








A Blue Claw Database Design Template:

Marina Management Reservations Software
 










A Blue Claw Database Design Article:

Why Choose Microsoft Access
 


Contact Information

Copyright 2000-2014 Blue Claw Database Design