Home  Fees/Services  Access Templates  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

Access VBA Tutorial
   
Access Programming Examples
Save Field Values Before Update

Old Value New Value Visual Basic Visual Basic for Microsoft Access 2007
Access 2007 Tutorial>Visual Basic Tutorial>Field Value New-Old Download VBA Tutorials  



Age Calculation
VBA Change Case
Calculate Running Sum
Concatenate Records
VBA CreateQueryDef
Database Path
Detail-Master Update
Field Validation VBA
Field Value New-Old
FindFirst Recordset
Get Version Number
VBA Global Parameters
VBA Global Variables
Labels as Links
VBA Outlook Email
List Box Files List
VBA Mail Merge
OutputTo Crosstab
Read Email Access
Sort Recordset
VBA Recordset Filters
Reference Form Field
RTF Report Email
VBA Select Case
VBA Transaction Processing

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

Private Sub Command4_Click()  ' this line is not part of this example

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... incase you want to do some validation checking before the value is saved to the database.



Don't Miss These MS Access Templates:

Document Revision Management Database Templates
Document Revision Control & Document Distribution Control & Tracking

HOA/Homeowner Association Management Microsoft Access Templates
HOA Management - Community Association Management, Home Owners Association Software.

Loan Process Management Access Templates
Mortgage Management,
Loan Processing Software &  Mortgage Process Tracking.

Student Loan/Grant Management Access Templates
Pell Grant Management Software.

Personnel Agency Access Template Database
Placement Agency Software, Custom Personnel Agency Management for Contractors and Consultants.

Rx/Prescription Assistance Plan Management Database Template
Rx Plan Software. Software for the Generation  & Tracking of Applications for Assistance Plans

Subscription Order Management Database Template
Subscription Manager - Custom Subscription Management Tool for Subscription Order Process Control.

Corporate Document Management Access Templates
Document Management Custom Document Search & Retrieval Software

 


Contact Information

Programming Visual Basic Tutorial

Access Visual Basic/VBA/VBScript/VB6 2007 2003 2000 All Windows Versions