On Change, copy new data

  • Thread starter prairiewind via AccessMonster.com
  • Start date
P

prairiewind via AccessMonster.com

I'm creating a report of only the changes that have been made in the database
since the last publication of the report. I don't want to list all the
information about a contact, only what has changed. I've created hidden
text boxes corresponding with the contact information. (i.e. - txtAddress
has a corresponding txtAddressChange.) I have in the txtAddress (and all the
other text boxes) in the On Change, code to copy the data to the new text box.
(Me.txtAddressChange = txtAddress). However, this copies the old information
and I'm wanting it to copy the new information. Is there a
better/different/right way to do this?
 
A

Arvin Meyer [MVP]

Bound records have controls with a Value property, the default property, and
an OldValue property. If you chnge the existing record, the Value is the
change, until the record is saved. Try using the BeforeUpdate event instead
of the Change event, which fires at each keystroke. The BeforeUpdate event
of the textbox fires when you leave that textbox. The BeforeUpdate event of
the record occurs before you leave the record or form. The OldValue property
is maintained until the record is saved. You might try something like this
in the BeforeUpdate event of the form: (air code)

Sub Form_BeforeUpdate (Cancel As Integer)
If Me.txtAddress = Me.txtAddress.OldValue Then
Me.txtAddressChange = Me.txtAddress
Else
Me.txtAddressChange = ""
End If

' Do the same for each value you want to capture
End Sub

To capture the Old Value, simply add the .OldValue property to Me.txtAddress
 
P

prairiewind via AccessMonster.com

Thanks, Alvin, for your help. It seems just adding the .oldValue to the end
of Me.txtAddress is more of what I was looking for and seems to work well.
Had the right idea, just didn't go far enough with it.
 
Top