Making QR Code ISO/IEC18004 in Microsoft Office Who Is the User

Using Barcode creation for ASP.NET Control to generate, create QR Code image in ASP.NET applications.

The first fact that must be established is who the user is and who has done the deed You can use an API call to find out who is actually using your application and altering data Create a new module by clicking Insert | Module on the VBE menu Enter the following declaration into the General area at the top of the module:

This sets up a link to the function GetUserName in the dynamic link library advapi32 (which is supplied as part of the Windows operating system) Next, enter a function to return the user name Enter the following code in the same module:

Using Barcode encoder for Font Control to generate, create barcode image in Font applications.

For the purposes of this example, I am using the Northwind database and the Customers table You can access the Northwind database by loading Access and clicking Sample in the center Navigation pane (Available Templates) and then clicking the Northwind icon Add the AuditTrail field to the Customers table On each table where you want an audit trail, you must add an extra field to hold the audit trail information Right-click the table name in the Navigation pane of Access and choose design mode Add a field as Memo type called AuditTrail Save the table design I have chosen a Memo type field so as to demonstrate how you can record every change a user makes to the data However, this may increase the size of the database too much and you may wish to use a standard text field instead, one that holds less information

Your table will act as the data feed for a form In the case of the Customers table, the Customers List form is a convenient one to use Open this form in Design mode and right-click the form Click Build Event in the pop-up menu and click Code Builder in the following window In the VBE module for the form, click the drop-down in the top-left corner of the module and click Form Click the drop-down in the top-right corner and click AfterUpdate Insert the following code into this event:

This code sets up two variables using the Dim statement, one as a Recordset object and one as a variant The reason that variant is used and not string is because initially this object has to be loaded with a null value and a string will not take a null The Recordset object is then set to point to the Customers table using the current record ID So long as the ID field is included in the data source for the form, you can refer to it using the Me object, even if it is not actually a field on the form The existing value of the AuditTrail field is loaded into the variable Temp (this is the point at which it may contain a Null value) The name of the Action (in this case, Edit), the user name, and the current date and time are all concatenated onto Temp using vertical bars as separators Temp now holds the latest details of the audit trail plus the previous details An Execute statement using an update query is then used to write back the new value of the AuditTrail field, and the RecSet object is closed You also need to add this same procedure to the BeforeInsert event To get to the BeforeInsert event, right-click the form and select Build Event Click Code Builder in the pop-up window and the VBE window for the form will be displayed Click Form in the top-left drop-down of the module window and click BeforeInsert in the top-right drop-down of the code module Change the action in the concatenated string to Insert instead of Edit Open the Customer List form in View mode and make a few changes to the data Open the Customers table and look at the AuditTrail field You will see that the information is starting to build up as to who did what and when You will now see why a memo field was used for the AuditTrail field and not text Text only allows 255 characters and this would soon be exhausted in a database with plenty of updates If you find you have to use a text field for the AuditTrail, do not concatenate with the previous value only store the current value:

One of the problems you may have noticed is that if the user deletes a record, then all of your wonderful audit trail disappears together with the record The way around this is not to allow users to delete records by setting the form property Allow Deletions to No