Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-10-29
3
Medium Priority
?
400 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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 85
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

705 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