Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-21-2018, 06:46 AM   #1
lana
Newly Registered User
 
Join Date: Feb 2010
Posts: 59
Thanks: 2
Thanked 0 Times in 0 Posts
lana is on a distinguished road
After_update problem

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

lana is offline   Reply With Quote
Old 06-21-2018, 06:49 AM   #2
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,369
Thanks: 128
Thanked 1,467 Times in 1,439 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: After_update problem

What's the code, and what's the purpose ?
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 06-21-2018, 07:14 AM   #3
lana
Newly Registered User
 
Join Date: Feb 2010
Posts: 59
Thanks: 2
Thanked 0 Times in 0 Posts
lana is on a distinguished road
Re: After_update problem

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

lana is offline   Reply With Quote
Old 06-21-2018, 07:20 AM   #4
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,369
Thanks: 128
Thanked 1,467 Times in 1,439 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: After_update problem

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?
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 06-21-2018, 07:40 AM   #5
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,211
Thanks: 13
Thanked 1,368 Times in 1,303 Posts
Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light
Re: After_update problem

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.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 06-21-2018, 07:45 AM   #6
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,369
Thanks: 128
Thanked 1,467 Times in 1,439 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: After_update problem

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.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 06-21-2018, 07:28 PM   #7
lana
Newly Registered User
 
Join Date: Feb 2010
Posts: 59
Thanks: 2
Thanked 0 Times in 0 Posts
lana is on a distinguished road
Re: After_update problem

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

lana is offline   Reply With Quote
Old 06-21-2018, 07:45 PM   #8
Beetle
Duly Registered Boozer
 
Join Date: Apr 2011
Location: Camp Swampy (Denver, CO)
Posts: 1,806
Thanks: 13
Thanked 458 Times in 449 Posts
Beetle will become famous soon enough Beetle will become famous soon enough
Re: After_update problem

Quote:
Originally Posted by lana View Post
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?
__________________
Sean Bailey

Dim Thirsty As String
Thirsty = "Insert Into Glass (Select Beer From Fridge)"
DoCmd.Execute Thirsty, dbPourAnotherOnError
Beetle is offline   Reply With Quote
Old 06-21-2018, 08:10 PM   #9
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,211
Thanks: 13
Thanked 1,368 Times in 1,303 Posts
Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light
Re: After_update problem

Quote:
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.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple commands in After_Update SoCal Forms 7 11-07-2012 01:20 PM
Combo box error message After_Update TIbbs Modules & VBA 1 12-18-2008 04:39 AM
Running after_update event davesmith202 Modules & VBA 11 09-23-2005 01:32 AM
After_Update not working after Add SDLevy Forms 3 04-14-2003 08:46 AM
Eliminating Screen Jitter on After_Update sbornstein1 Forms 1 07-22-2001 04:02 PM




All times are GMT -8. The time now is 03:24 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World