Solved

Detect last object clicked (on Access 2007 form) in BeforeUpdate event procedure

Posted on 2014-10-29
3
377 Views
Last Modified: 2014-10-29
In an Access 2007 form BeforeUpdate event procedure, is there any way of finding out the last object clicked on?  (The form's ActiveControl property doesn't do it, because BeforeUpdate fires before the object clicked on becomes active.)

In particular: on a form with a subform, clicking on the subform area triggers the main form BeforeUpdate event.  In the BeforeUpdate event procedure, I would like to know whether the subform was the last thing clicked on, so that I can tailor my mainform validation accordingly.
0
Comment
Question by:MatthewNicoll
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40411650
Not unless you store this sort of data somewhere. If you truly must do that, then you can create a Form-level varialbe and use code like this in the OnExit event of each control:

sLastControl = Me.Name

Assuming the Form-Level variable is named "sLastControl", of course.

That said: You refer to "Mainform Validation", but you'd not be able to do that from the Subform, since by the time you hit the Subform the data in the Mainform has already been saved - so there'd be no need to validate, since you really couldn't do much about it.

In most common scenarios, you'd validate the Parent record BEFORE you add or modify a CHILD record. This is the reasoning behind the event sequence in Access.

However, if you could explain further about why you need to hold off on validating a Parent until the user has interacted with the Child, we might be able to dig a little deeper.
0
 

Author Closing Comment

by:MatthewNicoll
ID: 40411777
Thanks Scott.  I just wanted to make sure there wasn't some Form property I had missed.
Basically, I wanted to let the user fill in main and sub form information in any order before doing validation, if possible.
(... and without unbinding all the controls!)
0
 
LVL 84
ID: 40412031
You can validate at any point, but if you do it AFTER you update the data, then there's really not much you can do about it - unless, of course, you're storing old values somewhere, and can "revert" them. Still, if you need that sort of control you're often better off using temporary tables, or moving to an unbound form.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

730 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