Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2006, 01:57 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mark change in a table

Hi,
  How can I tell if a record has been changed in a table?
Is there a way to record the date that a change is made?

Thanks,
Dave

 
Old October 13th, 2006, 09:03 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If a record is changed can it be set to a different color or font? I need to be able to pick out a changed record or tell the computer how to pick out a changed record.

 
Old October 13th, 2006, 02:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You are looking for something analogous to a trigger in SQL Server. There are no table triggers in Access, so you need to do this programatically in the front end.

You can put 2 columns in the table called DateCreated, and one called DateModified, and set their data type to Date/Time. Then set their default values to Now().

Create two more fields in the table called WhoCreated and WhoModified, and data type Text.

Then on your data entry form, add this code:

On the Before Insert Event:

Dim sUser As String
sUser = (Environ$("Username"))
Me.WhoCreated = sUser

On the Before Update Event:
Dim sUser As String
sUser = (Environ$("Username"))
Me.WhoModified = sUser
Me.DateModified = Now()

Remember to put these 4 controls on your form, but then set their Visible property to No.

This will tell you who created a record, and who modified a record the last time, if your users are using the form.

You can then do a query on DateCreated and DateModified and select those where these values are not equal (since they will be equal if the record is created but never modified.)

Does that help?


mmcdonal
 
Old October 23rd, 2006, 10:40 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

works great :D

Thanks mmcdonal!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Change border color for every cell of a table jdang67 CSS Cascading Style Sheets 10 May 6th, 2010 12:21 AM
change table to dbo hepsy.i ASP.NET 1.0 and 1.1 Professional 1 August 7th, 2007 07:41 AM
Does reference to a table change when db split? Loralee Access 2 June 29th, 2005 09:03 PM
change table structure Duncan SQL Server 2000 1 March 3rd, 2005 04:10 AM
Change lines in a Table.... cybercross Classic ASP Basics 1 October 2nd, 2004 06:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.