Solved

Capturing Choices from frmMainMenu

Posted on 2011-03-20
5
395 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now