Before Update event not working...

L

Lyndon

Hi all,

I've got a subform within a form in Access in datasheet mode. The
source object is a table in my database and when I open the form, the
data is shown in the subform datasheet correctly. I can make changes
to the data in the subform and they are updated in the database table
as expected. However, the Before Update event is not being triggered
when I update the data in my sub form. I have created an
EventProcedure for the Before Update event for the form (not the
sub-form) and put a message box in the procedure just to check that
it's working but it isn't... this is my event procedure coude if it
will be of any assistance:

Private Sub Form_BeforeUpdate(Cancel As Integer)
MsgBox "BeforeUpdate", vbOKOnly
End Sub

If I put a breakpoint at the MsgBox line and run the application it
never gets into this procedure... it seems that the Before Update event
is not being called. Any ideas..?

Thanks in advance,
Lyndon.
 
R

Rick Brandt

Lyndon said:
Hi all,

I've got a subform within a form in Access in datasheet mode. The
source object is a table in my database and when I open the form, the
data is shown in the subform datasheet correctly. I can make changes
to the data in the subform and they are updated in the database table
as expected. However, the Before Update event is not being triggered
when I update the data in my sub form. I have created an
EventProcedure for the Before Update event for the form (not the
sub-form) and put a message box in the procedure just to check that
it's working but it isn't... this is my event procedure coude if it
will be of any assistance:

Private Sub Form_BeforeUpdate(Cancel As Integer)
MsgBox "BeforeUpdate", vbOKOnly
End Sub

If I put a breakpoint at the MsgBox line and run the application it
never gets into this procedure... it seems that the Before Update
event is not being called. Any ideas..?

Thanks in advance,
Lyndon.

Changing records in the subform will not trigger the update events in the
parent form because no updates are occurring there. Each form is completely
separate in that regard.
 
K

Ken Sheridan

Lyndon:

A subform's underlying form object has its own BeforeUpdate event procedure
into which you should put any code you wish to execute before a row in the
subform's underlying table is updated. The parent form's event will only
fire before the table or query underlying the parent form itself is updated.

The BeforeUpdate event procedure is most commonly used to validate data as
it has a Cancel argument whose return value can be set to True if the
validation criteria are not met.

Ken Sheridan
Stafford, England
 
L

Lyndon

Thanks for the replies... I realise that the subform may have its own
BeforeUpdate event but when I look through the properties of the
subform, there is no Update events shown (BeforeUpdate, AfterUpdate
etc). How then do I add a call from the subform to my event handler..?
 

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

Top