PC Review


Reply
Thread Tools Rate Thread

'Before update' event triggering

 
 
Dorian
Guest
Posts: n/a
 
      6th Apr 2009
I have some code which checks if a record has been emailed.
The check is triggered whenever I move to a new record.
I have the check in the 'before update event'
When the user clicks the 'email' button, I have to do a save to ensure any
pending record changes are saved before I generate the email. This in turn
triggers the 'before update' event.
I am then in a situation where the user has clicked 'email' but then
receives a prompt that he has not emailed yet. I dont want to show the prompt
if it results from clicking 'email'.
How can I arrange this better so I don't have this problem? Thanks.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Reply With Quote
 
 
 
 
PJFry
Guest
Posts: n/a
 
      6th Apr 2009
I need a little clarification. It sounds like you have two before update
events. One on the form level (...The check is triggered whenever I move to
a new record.
I have the check in the 'before update event'
....) and one on the click level for you command button (When the user clicks
the 'email' button...This in turn
triggers the 'before update' event.). Is that correct? Or is there just a
before update on the click?

Assuming it is on only the click, you can do a DLookup for the value of the
e-mail on your click event. It would read something like this:

If IsNull(DLookup("emailFlag","table","recordID = " & Me.ID) Then
Send the e-mail
Record e-mail sent
Else
Msgbox that message has already been sent
End If

Just replace the DLookup items with the ones that correspond to your table.

Does that make sense?


--
Regards,

PJ
Please rate this post using the vote buttons if it was helpful.



"Dorian" wrote:

> I have some code which checks if a record has been emailed.
> The check is triggered whenever I move to a new record.
> I have the check in the 'before update event'
> When the user clicks the 'email' button, I have to do a save to ensure any
> pending record changes are saved before I generate the email. This in turn
> triggers the 'before update' event.
> I am then in a situation where the user has clicked 'email' but then
> receives a prompt that he has not emailed yet. I dont want to show the prompt
> if it results from clicking 'email'.
> How can I arrange this better so I don't have this problem? Thanks.
> -- Dorian
> "Give someone a fish and they eat for a day; teach someone to fish and they
> eat for a lifetime".

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      6th Apr 2009
On Mon, 6 Apr 2009 09:49:02 -0700, Dorian <(E-Mail Removed)>
wrote:

>I have some code which checks if a record has been emailed.
>The check is triggered whenever I move to a new record.
>I have the check in the 'before update event'
>When the user clicks the 'email' button, I have to do a save to ensure any
>pending record changes are saved before I generate the email. This in turn
>triggers the 'before update' event.
>I am then in a situation where the user has clicked 'email' but then
>receives a prompt that he has not emailed yet. I dont want to show the prompt
>if it results from clicking 'email'.
>How can I arrange this better so I don't have this problem? Thanks.
>-- Dorian
>"Give someone a fish and they eat for a day; teach someone to fish and they
>eat for a lifetime".


Please post your code.
--

John W. Vinson [MVP]
 
Reply With Quote
 
Dorian
Guest
Posts: n/a
 
      6th Apr 2009
Before I execute my Email function I do:
If Me.dirty then me.dirty = false
to save any pending changes
This triggers the Before Update event.

Its perfectly ok to email a record more than once but I need to issue a
reminder on records created but not emailed. I do not want the reminder to
appear when they are in the process of emailing (ie. when they click the
email button)
Hope this makes sense.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"PJFry" wrote:

> I need a little clarification. It sounds like you have two before update
> events. One on the form level (...The check is triggered whenever I move to
> a new record.
> I have the check in the 'before update event'
> ...) and one on the click level for you command button (When the user clicks
> the 'email' button...This in turn
> triggers the 'before update' event.). Is that correct? Or is there just a
> before update on the click?
>
> Assuming it is on only the click, you can do a DLookup for the value of the
> e-mail on your click event. It would read something like this:
>
> If IsNull(DLookup("emailFlag","table","recordID = " & Me.ID) Then
> Send the e-mail
> Record e-mail sent
> Else
> Msgbox that message has already been sent
> End If
>
> Just replace the DLookup items with the ones that correspond to your table.
>
> Does that make sense?
>
>
> --
> Regards,
>
> PJ
> Please rate this post using the vote buttons if it was helpful.
>
>
>
> "Dorian" wrote:
>
> > I have some code which checks if a record has been emailed.
> > The check is triggered whenever I move to a new record.
> > I have the check in the 'before update event'
> > When the user clicks the 'email' button, I have to do a save to ensure any
> > pending record changes are saved before I generate the email. This in turn
> > triggers the 'before update' event.
> > I am then in a situation where the user has clicked 'email' but then
> > receives a prompt that he has not emailed yet. I dont want to show the prompt
> > if it results from clicking 'email'.
> > How can I arrange this better so I don't have this problem? Thanks.
> > -- Dorian
> > "Give someone a fish and they eat for a day; teach someone to fish and they
> > eat for a lifetime".

 
Reply With Quote
 
Dorian
Guest
Posts: n/a
 
      6th Apr 2009
Its not feasible to post all the code. It's thousands of lines and intermixed
with other code that has nothing to do with this issue.
Basically when a record is created but not emailed, I display a
Yes/No/Cancel message box. If the user clicks No, I save a 'need to email'
reminder record in a table. This is all done in the BeforeUpdate event.

The problem is that the BeforeUpdate event is also triggered when I actually
do the email as I have to do a
If me.dirty then me.dirty = false
beforehand to ensure all pending changes are saved.
This in turn triggers the BeforeUpdate event and thus the reminder - which I
don't need since I am already in the process of emailing the record.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"John W. Vinson" wrote:

> On Mon, 6 Apr 2009 09:49:02 -0700, Dorian <(E-Mail Removed)>
> wrote:
>
> >I have some code which checks if a record has been emailed.
> >The check is triggered whenever I move to a new record.
> >I have the check in the 'before update event'
> >When the user clicks the 'email' button, I have to do a save to ensure any
> >pending record changes are saved before I generate the email. This in turn
> >triggers the 'before update' event.
> >I am then in a situation where the user has clicked 'email' but then
> >receives a prompt that he has not emailed yet. I dont want to show the prompt
> >if it results from clicking 'email'.
> >How can I arrange this better so I don't have this problem? Thanks.
> >-- Dorian
> >"Give someone a fish and they eat for a day; teach someone to fish and they
> >eat for a lifetime".

>
> Please post your code.
> --
>
> John W. Vinson [MVP]
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      6th Apr 2009
On Mon, 6 Apr 2009 12:59:01 -0700, Dorian <(E-Mail Removed)>
wrote:

>Its not feasible to post all the code. It's thousands of lines and intermixed
>with other code that has nothing to do with this issue.
>Basically when a record is created but not emailed, I display a
>Yes/No/Cancel message box. If the user clicks No, I save a 'need to email'
>reminder record in a table. This is all done in the BeforeUpdate event.
>
>The problem is that the BeforeUpdate event is also triggered when I actually
>do the email as I have to do a
>If me.dirty then me.dirty = false
>beforehand to ensure all pending changes are saved.
>This in turn triggers the BeforeUpdate event and thus the reminder - which I
>don't need since I am already in the process of emailing the record.


Sounds like you need to set some sort of flag in the click event code to tell
Beforeupdate that it's ok. This could be a global variable or (better) an
invisible control on the form. Since you know at this point that the record
has been saved, the BeforeUpdate event could simply set Cancel to True and
return.
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Not Triggering After Update Event Balfour211 Microsoft Access 6 20th Jan 2010 03:51 PM
Framesets - Event in frame 'A' triggering update of frame 'B' -How ? JAW Microsoft ASP .NET 2 9th Nov 2004 07:54 PM
Framesets - Event in frame 'A' triggering update of frame 'B' -How ? JAW Microsoft VB .NET 1 9th Nov 2004 02:27 PM
Triggering an event David S. Microsoft Access VBA Modules 3 19th Apr 2004 12:41 AM
After Update event not triggering after Paste Confirm Krista Krauklis Microsoft Access Form Coding 0 19th Aug 2003 07:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:59 AM.