i have audit trail module using this code...
Option Compare Database
Option Explicit
Public Function AuditTrail()
On Error GoTo Err_Audit_Trail
'ACC2000: How to Create an Audit Trail of Record Changes in a Form
'http://support.microso ft.com/default.aspx?sc id=kb;en-us;197592
Dim MyForm As Form
Dim ctl As Control
Dim sUser As String
Set MyForm = Screen.ActiveFo rm
' sUser = "User: " & UsersID 'You need to identify your users if you are not using Access security with workgroups. sUser = CurrentUser()
'If new record, record it in audit trail and exit function.
If MyForm.NewRecor d = True Then
MyForm!Updates = MyForm!tbAuditT rail & "New Record added on " & Now & " by " & sUser & ";"
Exit Function
End If
'Set date and current user if the form (current record) has been modified.
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & vbLf & "Changes made on " & Now & " by " & sUser & ";"
'Check each data entry control for change and record old value of the control.
For Each ctl In MyForm.Controls
'Only check data entry type controls.
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox
If ctl.Name = "tbAuditTra il" Then GoTo TryNextControl 'Skip AuditTrail field.
'If new and old value do not equal
If ctl.Value <> ctl.OldValue Then
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & ctl.Name & ": Changed From: " & ctl.OldValue & ", To: " & ctl.Value
'If old value is Null and new value is not Null
ElseIf IsNull(ctl.OldV alue) And Len(ctl.Value) > 0 Or ctl.OldValue = "" And Len(ctl.Value) > 0 Then
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & ctl.Name & ": Was Previoulsy Null, New Value: " & ctl.Value
'If new value is Null and old value is not Null
ElseIf IsNull(ctl.Valu e) And Len(ctl.OldValu e) > 0 Or ctl.Value = "" And Len(ctl.OldValu e) > 0 Then
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & ctl.Name & ": Changed From: " & ctl.OldValue & ", To: Null"
End If
End Select
TryNextControl:
Next ctl
Exit_Audit_Trai l:
Exit Function
Err_Audit_Trail :
If Err.Number = 64535 Then 'Operation is not supported for this type of object.
Exit Function
ElseIf Err.Number = 2475 Then 'You entered an expression that requires a form to be the active window
Beep
MsgBox "A form is required to be the active window!", vbCritical, "Invalid Active Window"
Else
Beep
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_Audit_Trai l
End Function
I HAVE A LOGON FORM THAT RETRIVES DATA FROM A TABLE.
IS IT POSSIBLE TO RETRIEVE THE CURRENT USER FROM A TABLE TO BE USED FOR MY AUDIT TRAIL.
7 3450 ADezii 8,834
Recognized Expert Expert
i have audit trail module using this code...
Option Compare Database
Option Explicit
Public Function AuditTrail()
On Error GoTo Err_Audit_Trail
'ACC2000: How to Create an Audit Trail of Record Changes in a Form
'http://support.microso ft.com/default.aspx?sc id=kb;en-us;197592
Dim MyForm As Form
Dim ctl As Control
Dim sUser As String
Set MyForm = Screen.ActiveFo rm
' sUser = "User: " & UsersID 'You need to identify your users if you are not using Access security with workgroups. sUser = CurrentUser()
'If new record, record it in audit trail and exit function.
If MyForm.NewRecor d = True Then
MyForm!Updates = MyForm!tbAuditT rail & "New Record added on " & Now & " by " & sUser & ";"
Exit Function
End If
'Set date and current user if the form (current record) has been modified.
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & vbLf & "Changes made on " & Now & " by " & sUser & ";"
'Check each data entry control for change and record old value of the control.
For Each ctl In MyForm.Controls
'Only check data entry type controls.
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox
If ctl.Name = "tbAuditTra il" Then GoTo TryNextControl 'Skip AuditTrail field.
'If new and old value do not equal
If ctl.Value <> ctl.OldValue Then
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & ctl.Name & ": Changed From: " & ctl.OldValue & ", To: " & ctl.Value
'If old value is Null and new value is not Null
ElseIf IsNull(ctl.OldV alue) And Len(ctl.Value) > 0 Or ctl.OldValue = "" And Len(ctl.Value) > 0 Then
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & ctl.Name & ": Was Previoulsy Null, New Value: " & ctl.Value
'If new value is Null and old value is not Null
ElseIf IsNull(ctl.Valu e) And Len(ctl.OldValu e) > 0 Or ctl.Value = "" And Len(ctl.OldValu e) > 0 Then
MyForm!Updates = MyForm!tbAuditT rail & vbCrLf & ctl.Name & ": Changed From: " & ctl.OldValue & ", To: Null"
End If
End Select
TryNextControl:
Next ctl
Exit_Audit_Trai l:
Exit Function
Err_Audit_Trail :
If Err.Number = 64535 Then 'Operation is not supported for this type of object.
Exit Function
ElseIf Err.Number = 2475 Then 'You entered an expression that requires a form to be the active window
Beep
MsgBox "A form is required to be the active window!", vbCritical, "Invalid Active Window"
Else
Beep
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_Audit_Trai l
End Function
I HAVE A LOGON FORM THAT RETRIVES DATA FROM A TABLE.
IS IT POSSIBLE TO RETRIEVE THE CURRENT USER FROM A TABLE TO BE USED FOR MY AUDIT TRAIL.
__1. Declare a Public Variable to represent the Current User in a Standard Code Module as in: - Public strCurrentUser As String
__2. Capture the User's Name from the LOGON Form and assign it to the Puiblic Variable as in: - strCurrentUser = "<name extracted from logon form>"
__3. Now you can refer to the Current User anywhere in your application by referencing the Public Variable assigned to him/her, namely, strCurrentUser.
how will the function determine the active current user?
how will i exactly extract the logged user...ty
ADezii 8,834
Recognized Expert Expert
how will the function determine the active current user?
__1. The Current Active User of the Database will always be returned by the CurrentUser() Function, the Current User as defined by the Operating System will be returned by Environ("UserNa me").
the curentuser() give me the default ms access security workgroup users..i want the values to be retrive from my table which i have used as reference of my log in form.
were geting near...hehe...e nviron("the selected user text value logged from combo box on a log in form") how will i exactly do this man..i really appreciate your help
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stefano |
last post by:
Hi all,
is it possibile to retrieve the current Windows User Handle from ASP code?
I would like to retrieve the correspondent in ASP for thi piece of ASP.NET
code:
WindowsIdentity id = HttpContext.Current.User.Identity as WindowsIdentity;
if (id != null)
{
|
by: Daniel Tonks |
last post by:
First, please excuse the fact that I'm a complete MySQL newbie.
My site used forum software that I wrote myself (in Perl) which, up until
now, has used flat files. This worked fine, however lately I've been wanting
to do more stuff with user accounts, and had been eying MySQL for over a
year.
Finally I've decided to start off small by converting the forum's account
system to a MySQL database (and convert the rest later after I'm...
|
by: Jim Richards |
last post by:
Hello all. I created the "student2" user account and set the password to
"student2". I then
went to Enterprise Manager and in the class_mgr database and in its
customers table, I gave this student2 user account access to the database
and set all permissions to the table. But when I log in to SQL Server using
this new userlogin, I can access the SQL Server Query Analyzer OK but when I
run the select * from customers; query I get...
|
by: Le |
last post by:
So here's my dilemma. I need an automated SQL Server (2000) job that
runs once once per hour.
This jobs should:
1) Retrieve unread email for the user "Le" from our Exchange Server,
and insert it into a table.
2) Retrieve unread email for the user "Smith", from from our Exchange
Server, and insert it into a table.
|
by: VMI |
last post by:
I'm using Binding Manager to retrieve the current table row that the user
clicked on (one highlighted row). But if I want to retrieve all the
highlighted rows, how can I do it?
This is the code to retrieve one row:
DataRowView rowViewAudit = (DataRowView)
((CurrencyManager)BindingContext).Current;
Now I want to modify this line so it retrieves all the highlighted rows. Is
it possible?
| |
by: Christopher Weaver |
last post by:
I want to set a value in a specific field in the current row of a DataSet.
This seems like the most basic thing to do but I can't find the syntax for
identifying the current row.
IOW, I can do this:
SomeRow = 'value';
But how do I set SomeRow to the row that the user is currently viewing?
|
by: jaYPee |
last post by:
I have currently using a dataset to access my data from sql server
2000. The dataset contains 3 tables that is related to each other.
parent/child/grandchild relationship. My problem is it's very slow to
retrieve records from sql server.
I'm using sqldataadapter.fill method to populate dataset.
Parent table contains more than 3,000 records and child table contains
more than 10,000 records and grandchild table contains more than
90,000...
|
by: rn5a |
last post by:
A SQL Server 2005 stored procedure expects a parameter 'UserID'
depending upon which it retrieves the no. of records & OrderIDs
corresponding to the 'UserID' from a DB table (note that OrderID &
UserID are two of the columns in the DB table). So for e.g. consider a
user whose UserID=6 & the DB table has 3 records whose UserID=6. In
other words, there are 3 OrderID records of the user whose UserID=6,
say, OrderID=8, OrderID=17 & OrderID=29....
|
by: kev |
last post by:
Hi all,
I have created a database for equipments. I have a form to register the
equipment meaning filling in all the particulars (ID, serial, type,
location etc). I have two buttons at the end of the form which is
submit and cancel. After i have clicked submit, the information is
stored directly into my corresponding database table. My problem here
is i need to retrieve back the information submitted to display all the
data that the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |