Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to find the opposite of OnCurrent Event for forms

Status
Not open for further replies.

MacroScope

Programmer
Jul 17, 2010
286
US
I'm trying to find which event is essentially the opposite of OnCurrent. I want to run instructions as the record changes from one to another, but not as it loses focus to another form or other object.

Access describes the OnCurrent event as:

"Occurs when the focus moves to a record, making it the current record, or when the form is refreshed or requeried."

I want the event which is the last thing that occurs before the focus moves to another record.

Does such an event exist? I've been looking high and low and can't find what I need.
 
Thanks for your help.

It sounds exactly like what I need but I can't get it to run. For the most part there are no error messages, and no discernable impact. I move through records with no problems, and no message boxes as I exit a recprd. It's as if it's not there.

On restarting the database I got an error message saying there was a syntax error in the From clause but I don't see it. I changed the name of the table Customers to the correct Query name the form is based on, but I am not sure if that is the problem. I stupidly named the Query RV/Trailers with a forward slash in the name. I thought nothing of it at the time, but I know you can't use it in a file name. Could the slash be causing the error?

Is this code functional with Access 2007 as well?
 
How are ya MacroScope . . .
MacroScope said:
[blue] I want to run instructions as the record changes from one to another, ... [/blue]
I use a [blue]Class Module[/blue] under two circumstances:
[ol][li]Nothing else will work![/li]
[li]The [blue]Class Module[/blue] fits the secnario and makes programming easier![/li][/ol]
The instructions you want to run will determine if you need the class module code provided by [blue]MajP[/blue]. Unfortunately we know not what those instructions are.

So ... what are they? ... its possible you may not need the class module.

[blue]Your Thoughts? . . .[/blue]


See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I'm good, AceMan, but apparently suffering from Alzheimer's! You have succeeded in humbling and embarrassing me in front of the world with your simple question, even if that wasn't your intent.

I wrote the post from the business where I'm working on the DB. At the time I had something in mind, but for the life of me I can't remember what it was! After I tried and failed with the code solution I went on to other things and got sidetracked.

I am sure that it was a simple routine I wanted to run, checking certain fields to make sure that something was done before leaving the record, and cancelling the record move and opening a reminder message box if it wasn't. The routine itself wasn't the issue, but only the trigger for it. It's really awful to have to admit to the memory lapse, but I'll remember (at least I hope I will!) when I'm back at it on Monday and will repost.
 
MacroScope . . .

Validation is typically performed in the [blue]Before Update[/blue] event. Here you can cancel updating and focus movement.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I agree with AceMan in that you may not need it. I have never come across something where I needed the recordExit event.

But with that said, this is a great piece of code to understand if you are trying to become a vba expert. I primarily code Access applications using custom classes, because as AceMan points out it can make reuse and programming easier and allows you extend the capabilities of Access objects. But if you are new to it there is a learning curve. This piece of code demonstrates some very powerful techniques
1) Binding an ADO recordset to an Access form
2) Developing and instantiating a custom class
3) Raising a custom event
4) Trapping a custom event
5) Instantiating an class with events.

This code will definitely work in 2007. However, since you are instantiating a module level variable, if you throw an untrapped error this code will appear to do nothing since the class variable will go out of scope. Not sure if that is what is happening in your case.
 
Thanks, MajP. As I said, I wrote the post from the business and I don't have the db here (plus, frankly, I don't want to work on it today anyway), but tomorrow when I'm back at it I'm sure I will remember what I wanted to accomplish with the routine. I'll repost the motivation and, even if it's not the most practical choice I'd still like to get it working, if for no other reason than to have it in my toolbox for another instance. I hope you're willing to talk me through it at that point.

I have another issue with a timer that I want to get working. I posted it as a separate thread at thread702-1653004 and I hope you will look at and consider ideas for that as well.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top