473,408 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to flag updates in a report

Hi. I am building a database, using Access 2007. I am a beginner. I have created a form that contains self created fields. Various people will be using the data base to input information re projects that they are responsible for. They will then be asked to update their information on weekly basis. I would like my report to flag the updates (e.g. highlight only fields with an updated value). Can this be done either with Access reporting tool or by exporting to Excel? Thanks in advance.
Oct 2 '13 #1
5 1535
jimatqsi
1,271 Expert 1GB
I have an application in which I need to report all the changes to the customer table and the inventory table daily. I do that by making a copy of each table and comparing all the relevant fields (it's not necessary to report changes to many of the fields). I print an exception report each evening showing which fields changed to which customers/items and then I rebuild the snapshot.

Jim
Oct 3 '13 #2
Put an audit trail in your database.

Build a table named tblAuditTrail.
Fields:
AuditTrailID (Autonumber)
DateTime (DateTime)
UserName (text)
FormName (text)
RecordID (Number)
Action (Text)
FieldName (Text)
OldValue (text)
NewValue (text)

Paste in this module and call it:

Expand|Select|Wrap|Line Numbers
  1. Sub AuditChanges(IDField As String, UserAction As String)
  2.     On Error GoTo AuditChanges_Err
  3.     Dim cnn As ADODB.Connection
  4.     Dim rst As ADODB.Recordset
  5.     Dim ctl As Control
  6.     Dim datTimeCheck As Date
  7.     Dim strUserID As String
  8.     Set cnn = CurrentProject.Connection
  9.     Set rst = New ADODB.Recordset
  10.     rst.Open "SELECT * FROM tblAuditTrail", cnn, adOpenDynamic, adLockOptimistic
  11.     datTimeCheck = Now()
  12.     strUserID = Environ("USERNAME")
  13.     Select Case UserAction
  14.         Case "EDIT"
  15.             For Each ctl In Screen.ActiveForm.Controls
  16.                 If ctl.Tag = "Audit" Then
  17.                     If Nz(ctl.Value) <> Nz(ctl.OldValue) Then
  18.                         With rst
  19.                             .AddNew
  20.                             ![DateTime] = datTimeCheck
  21.                             ![UserName] = strUserID
  22.                             ![FormName] = Screen.ActiveForm.NAME
  23.                             ![Action] = UserAction
  24.                             ![RecordID] = Screen.ActiveForm.Controls(IDField).Value
  25.                             ![Fieldname] = ctl.ControlSource
  26.                             ![OldValue] = ctl.OldValue
  27.                             ![NewValue] = ctl.Value
  28.                             .Update
  29.                         End With
  30.                     End If
  31.                 End If
  32.             Next ctl
  33.         Case Else
  34.             With rst
  35.                 .AddNew
  36.                 ![DateTime] = datTimeCheck
  37.                 ![UserName] = strUserID
  38.                 ![FormName] = Screen.ActiveForm.NAME
  39.                 ![Action] = UserAction
  40.                 ![RecordID] = Screen.ActiveForm.Controls(IDField).Value
  41.                 .Update
  42.             End With
  43.     End Select
  44. AuditChanges_Exit:
  45.     On Error Resume Next
  46.     rst.Close
  47.     cnn.Close
  48.     Set rst = Nothing
  49.     Set cnn = Nothing
  50.     Exit Sub
  51. AuditChanges_Err:
  52.     MsgBox Err.Description, vbCritical, "ERROR!"
  53.     Resume AuditChanges_Exit
  54. End Sub
Oct 3 '13 #3
Thanks for your quick reply. Will give it a try shortly.
--------------
@jimatqsi
Oct 3 '13 #4
Thank you for your quick reply and detailed answer. Looks promising! I may need some more help with your solution as I am a beginner but I will give it a try for sure.
----------
@KSReynolds
Oct 3 '13 #5
Building the table and module were quite easy. Thanks. Now where and how do I paste the module in?
-------------
@KSReynolds
Oct 3 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
3
by: bbdata | last post by:
what would be an equivalent of OnCurrent event/Forms , in detail section of the Report? i have a subreport with just one (visible)field, bounded to a query. subreport is in detail section of main...
3
by: Jim Archer | last post by:
Hi All... I'm been fighting this problem for a few days now, and it seems like it should be simple. But the solution has eluded me so far... I need to flag a record when it is updated or when...
3
by: Henry Stockbridge | last post by:
Hi, I need a way of bypassing the Report_Close procedure (or come up with another event to handle the Update Query.) Right now, if I set the value of Report_NoData to Cancel=True, the...
2
by: Steve | last post by:
I have set up a db at work, I work in a flying school. All students and other pilots are included in this db, along with particulars such as Medical Certificate expiry date. I need to have the db...
4
by: pmcgover | last post by:
I enjoyed Paul Barry's September article in Linux Journal entitled, "Web Reporting with MySQL, CSS and Perl". It provides a simple, elegant way to use HTML to display database content without any...
24
by: djsdaddy | last post by:
Good Day to All, This is my first post to the scripts, and I'm glad to be part of a community of experts that can pull me out of the holes that I sometimes dig for myself. I am running XP and Access...
0
by: kamboj.shalabh | last post by:
Hi to all, Well, I am working on dotnet 2005 with crystal reports 10 and backend as sql server. I am facing a problem while loading a report. Actually the issue is, when I load report it takes...
3
by: Connell | last post by:
I am using a command button from a form (Access 2000) to produce a report. The form and the report each have a subform (subreport). Here is the expression that produces a total for one field on the...
1
by: Dennis Hartmann | last post by:
ACC 97 - Report with multiple grouping levels. Report footers have text controls with controlsource: "=Avg()". The report's Recordsource was changed so field1 contains null (instead of zero) for no...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.