Trying to check what exaclty changed AfterUpdate/BeforeUpdate

  • Thread starter Thread starter Heinrich Wessel
  • Start date Start date
H

Heinrich Wessel

I'm working on an employee database, and need to have it send an e-
mail if certain items change (name & address). The e-mail part works,
but checking to see what in the record changed using AfterUpdate
doesn't seem to.

Private Sub Form_AfterUpdate()

If "Me!Address" <> "Tables![Addresses]![Address]" Then

Dim intAnswer As Integer
intAnswer = MsgBox("You have made changes this employees personnel
file. Would you like to send changes to the appropriate parties?",
vbQuestion + vbYesNo, "Changes Detected")

If intAnswer = vbYes Then
'code here for e-mail
End If
End If
End Sub

Basically, my If statements always returns true, and always gives me
the message box regardless of which fields changed. I'm guessing its
a problem with the logic, and unfortunalty I am new to VBA, so any
help would be appreciated.
 
Heinrich said:
I'm working on an employee database, and need to have it send an e-
mail if certain items change (name & address). The e-mail part works,
but checking to see what in the record changed using AfterUpdate
doesn't seem to.

AfterUpdate is too late. The old value is gone.

Private Sub Form_AfterUpdate()

If "Me!Address" <> "Tables![Addresses]![Address]" Then

That is NOT how you retrieve a value from a table. You would use the
DLookup() function. Fortunately, you don't even need to do that. Use the
form's BeforeUpdate event and compare each control's Value property to its
OldValue property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top