Solved

Capturing Choices from frmMainMenu

Posted on 2011-03-20
5
423 Views
Last Modified: 2012-05-11
Hi,

I have a form called frmMainMenu (!).
It has 10 menu options which is basically calling other forms.

I want an Audit log - if possible by coding ONLY the frmMainMenu.

I.e. I want a line of VBA in the frmMainMenu which captures the option chosen from the menu.

The idea is that I get an audit like "UserA chose Menu Option xxxxx at 6pm". Under what "event" do I write this code??

I do NOT want to write the code in each of the 10 options - I want to write it just once - in the main menu


0
Comment
Question by:Patrick O'Dea
5 Comments
 
LVL 21
ID: 35176587
I would use an append query to add the data to a table. You could run this append query  just before you open the form.

I find it best to use separate field in the audit log table:
LogDate  - date Time - default Now()
WindowsUserName
DatabaseUserName
ObjectName
Action
ActionDescription


0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 35176595
I have been doing Audit logs in my database for 15+ years in Access. I have found it best to create a public function that you can call.  I also have find it best to use the On load and On close events of forms and reports to call the logging function. This way it does not matter how/where the form or report was opened.
0
 
LVL 13

Expert Comment

by:lee555J5
ID: 35176646
Are your 10 options part of an option group? If so, you can code your audit in the option group's AfterUpdate event. If not, you may want to redesign your form using the option group solution.

If you draw a frame control with toggle buttons on your form using the wizard, it does most of the work for you. The frame is now your option group's container. Add your next-form-opening code and your audit code to the frame's AfterUpdate event.

Lee
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35176677
The 10 menu Items should be in an Option Group control from which you can select only one item at a time.  This control is give a name such as Frame1 and each option box is given a value 1 to 10.   The Option Group  has a click event that will fire when any of the ten items are selected.  You can determine which one fired by examining the value of the control after the click.  By naming the controls opt1 to opt10 you can determine the name of the control that fired by appending the value of the Option Group to "opt".   Assuming you have no trouble aggregating the components of the audit string, to answer the question, put the code in the click event of the Option Group.

0
 

Author Closing Comment

by:Patrick O'Dea
ID: 35176694
Thanks very much .

That will do nicely.

You are 14 years ahead of me!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question