After_update problem (1 Viewer)

lana

Registered User.
Local time
Today, 16:40
Joined
Feb 10, 2010
Messages
92
Hi there,


I would appreciate if someone could help me with this problem.


I have a sub-form on a form. In this sub form data must be entered.

I need to execute a code when each record is entered in the sub-form.


I wrote the code in the "After_Update" procedure of this sub-form.


BUT ---- it doesn't run . When I include a toggle (break point) in a line , then this procedure is executed correctly.????


Help is desperately needed, PLEASE.



Thanks
 

Minty

AWF VIP
Local time
Today, 12:10
Joined
Jul 26, 2013
Messages
10,355
What's the code, and what's the purpose ?
 

lana

Registered User.
Local time
Today, 16:40
Joined
Feb 10, 2010
Messages
92
The code does not matter. Whatever the code is, it doesn't go to the "After_Update" procedure.

The purpose is : when a line of record is entered, some fields must be updated in another table. The code works fine but works only when I add a break point and run it line by line.
Thanks
 

Minty

AWF VIP
Local time
Today, 12:10
Joined
Jul 26, 2013
Messages
10,355
I suspect the code does matter, as it doesn't work as you expect.

Normally validation or triggered events are fired / checked in the BeforeUpdate event, as this is called before a record is saved.

The after update event on a record level is not terribly reliable from memory, you might be better to check if the record is dirty?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:10
Joined
Feb 19, 2002
Messages
42,981
The AfterUpdate event is the correct event for doing something AFTER a record is saved. Presumably, you have code in the BeforeUpdate event that actually validates the record.

If the AfterUpdate event is not running, it is because the record isn't dirty and therefore wasn't saved. It would be helpful for us to see ALL the code in the form's module.

BTW, saving data in multiple tables is not good practice unless what you are doing is creating a change log.
 

Minty

AWF VIP
Local time
Today, 12:10
Joined
Jul 26, 2013
Messages
10,355
In addition to Pat's comments, I believe the Forms after update event will fire after any field is updated, you really need a complete record update to be processed I assume.
 

lana

Registered User.
Local time
Today, 16:40
Joined
Feb 10, 2010
Messages
92
Thank you all.

I solved the problem with Me.refresh and also I changed the code procedure to a specific field "lost focus".
It works like a charm.
Cheers
 

Beetle

Duly Registered Boozer
Local time
Today, 06:10
Joined
Apr 30, 2011
Messages
1,808
Thank you all.

I solved the problem with Me.refresh and also I changed the code procedure to a specific field "lost focus".
It works like a charm.
Cheers

So now the code will fire every time a user tabs through that control, whether they updated the record or not. Are you sure that's what you want?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:10
Joined
Feb 19, 2002
Messages
42,981
I solved the problem with Me.refresh and also I changed the code procedure to a specific field "lost focus".
Not the correct solution. You really need to figure out why the BeforeUpdate and AfterUpdate events are not firing. Do you understand that those events do not fire UNTIL, you either force the record to save or cause focus to move to a new record.

The Me.Refresh is a method to have Access go to the table and bring back updates. A BYPRODUCT of Refresh is that Access FIRST causes the record to save. And as Beetle has already mentioned, you REALLY do not want to perform this action is someone is just passing through and didn't make any changes.

Move the code back to the Form's AfterUpdate event since that is actually the ONLY time you want this to run. If my explanation didn't resolve the issue, please post the form and we'll look at it.
 

Users who are viewing this thread

Top Bottom