- Local time
- Today, 13:23
- Joined
- Feb 28, 2001
- Messages
- 30,552
Yes, forcing the "Dirty" flag to FALSE would force an update and trigger all update-related FORM events.
quite hardI'm not sure that "BeforeUpdate" satisfies my need. If I'm reading correctly, "BeforeUpdate" is executed anytime any field on the form is changed? My dilemma is I need to trigger the email after all four address fields have POSSIBLY been updated. When all four fields have been changed, that's easy; I can check for that condition and trigger the email anytime while I'm on the current record. However that's not always the case; an individual could move to a new address in the same city and/or state, in which case the all-four-fields-changed trigger doesn't work. I can only trigger the check once the user leaves the current record.
I think I'm stuck.
dim tfEmail As boolean
private sub form_beforeupdate(cancel as integer)
tfEMail = (AfterFullAddress <> BeforeFullAddress)
end if
private sub form_afterupdate()
if (tfEMail = True) Then
'your code here to email it
end if
tfEMail = False
end sub
I'm honored that both of you have been helping me!oh my goodness
>i'm glad
>both of you arnelgp and the theDBGuy, wow
>you've been my light in AWF
thanks for the recognitionI'm honored that both of you have been helping me!
That sounds normal to me. The instant that you start going to a different record, Access is saving that current record, which triggers the event.When I move to a new record, it appears that "BeforeUpdate" is triggered before the form is actually rendered. I looked for more "Dirty=false" statements but can't find any. It's not doing any harm because the address hasn't been changed at this point, but it seems unusual.
Not sure what you mean by well known condition. As I pointed out before, odds also exist that your suggestion of variables could result in an inaccurate result, too. Neither of our suggestions was 100% certain never to produce inaccurate results. I guess if either of us wanted to get to the "zero chance of inaccuracy" spot, then we would both have suggested a table-driven method only...Isaac,
Are you really willing to knowingly write code that will fail under well known conditions despite their lack of frequency?
I think you meant to type true in first line.If Me.Dirty = False Then Me.Dirty = False End If
Sorry. All of the Dirty commands were part of an If...Then as you noted. In any event, I commented them all out until I'm certain that everything is functioning as it should. From the looks of it, the Dirty commands were overkill.The "Dirty = False" statements should ALWAYS be encased in an If statement. You don't want to force a record to save unless it was changed.
Code:If Me.Dirty = False Then Me.Dirty = False End If
The Form's BeforeUpdate event should only ever run if the record was dirtied. If it is running every time you scroll to a new record, something in your code is dirtying the record and it shouldn't be.