Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2007

Tip: Looking for answers? Try searching our database.

On Change, copy new data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
prairiewind - 18 Dec 2007 15:26 GMT
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?
Arvin Meyer [MVP] - 18 Dec 2007 16:37 GMT
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
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

> I'm creating a report of only the changes that have been made in the
> database
[quoted text clipped - 9 lines]
> and I'm wanting it to copy the new information.  Is there a
> better/different/right way to do this?
prairiewind - 20 Dec 2007 01:20 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.