SubForm's BeforeUpdate Event Not Firing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I just need to notify the user that the record displayed in the continuous
subform has been saved. To do this, I've written this procedures:

Private Sub Form_AfterInsert()
MsgBox "new detail saved"
End Sub

Private Sub Form_AfterUpdate()
MsgBox "change saved"
End Sub

While the afterinsert event always occurs and I see the msgbox, the
ufterupdate event is not triggered. If I modify a record and then click on
another row, the previous record is saved and I should see the msgbox, but
nothing happens.
Does anybody have an idea of what could be wrong?

many thanks
Massimo
 
Hi Max

These are usually reliable events, so if they are not firing in your case,
it is probably an indication of corruption.

Decompile a copy of the database by entering something like this at the
command prompt while Access is not running. It is all one line, and include
the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"
Then compact the database.

If that does not solve the issue, rebuild the database by following the 6
steps for the first symptom in:
Recovering from Corruption
at:
http://members.iinet.net.au/~allenbrowne/ser-47.html


BTW, make sure you are not doing anything that dirties the form again in
Form_AfterUpdate, because it will then need to save again, which will
trigger the event again, which dirties it again, which ...
 
Hi Allen,
Thanks for your reply. I've tried both decompiling the db and rebuilding it
in a new file, but the afterupdate event is still not triggered. So probabily
it is not caused by a corruption issue, also because now I've tried to put
the same code in a very old backup of the file, and also there does not work.
But what could be then? I really don't have any idea. Could it be that the
file is ok but i miss something somewhere?
What I can tell for sure is:
1. the code
Private Sub Form_AfterUpdate()
MsgBox "change saved"
End Sub
is written in the correct form module (the subform module).
2. it is a continuous subform, so I start changing something in the first
row, the little icon in the record selector column change to a pencil, the
status of the recod becomes 'dirty', then I click on a different record, the
changes are saved, but the afterupdate event is not fired!
Any idea?

thanks a lot,
Massimo
 
If you:
- open the form in design view, and
- open the Properties box to view the properties of the form,
do you see:
[Event Procedure]
next to the After Update property?

There are cases where this setting goes missing, and the code then does not
trigger because it is not associated with the event.
 
Hi Allen,

you're right! it was blank.. now it works. I don't know why was not
there, I've created the afterinsert and afterupdate procedures exactly in the
same way (from the code window, choosing the event in the combobox in the
right upper part of the window) one worked, the other not ... mystery...

thanks a lot and have a nice day.
Massimo


Allen Browne said:
If you:
- open the form in design view, and
- open the Properties box to view the properties of the form,
do you see:
[Event Procedure]
next to the After Update property?

There are cases where this setting goes missing, and the code then does not
trigger because it is not associated with the event.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

max said:
Hi Allen,
Thanks for your reply. I've tried both decompiling the db and rebuilding
it
in a new file, but the afterupdate event is still not triggered. So
probabily
it is not caused by a corruption issue, also because now I've tried to put
the same code in a very old backup of the file, and also there does not
work.
But what could be then? I really don't have any idea. Could it be that the
file is ok but i miss something somewhere?
What I can tell for sure is:
1. the code
Private Sub Form_AfterUpdate()
MsgBox "change saved"
End Sub
is written in the correct form module (the subform module).
2. it is a continuous subform, so I start changing something in the first
row, the little icon in the record selector column change to a pencil, the
status of the recod becomes 'dirty', then I click on a different record,
the
changes are saved, but the afterupdate event is not fired!
Any idea?

thanks a lot,
Massimo
 
Back
Top