PC Review


Reply
Thread Tools Rate Thread

Before Update event not working...

 
 
Lyndon
Guest
Posts: n/a
 
      7th Sep 2006
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.

 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      7th Sep 2006
Lyndon wrote:
> 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.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      7th Sep 2006
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

"Lyndon" wrote:

> 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.
>
>


 
Reply With Quote
 
Lyndon
Guest
Posts: n/a
 
      8th Sep 2006
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..?

 
Reply With Quote
 
Rick Brandt
Guest
Posts: n/a
 
      8th Sep 2006
Lyndon wrote:
> 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..?


Sounds like you looked at the properties of the subform *control*. The form
shown within the control is a plain old form and they all have the same
properties and events.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
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
DLookup query source stops working in combo box after update event Peter Microsoft Access Forms 0 3rd Feb 2009 11:18 PM
Run a Event Procedure and Macro in the Before Update Event Frank Microsoft Access Form Coding 5 12th Jan 2008 12:50 AM
After Update event not working for deletions Jim Microsoft Access Form Coding 1 1st Jun 2004 03:13 PM
after update event equation not working Jim Tully Microsoft Access Form Coding 1 16th Sep 2003 06:29 PM
Re: after update event equation not working Albert D. Kallal Microsoft Access Form Coding 0 16th Sep 2003 08:33 AM


Features
 

Advertising
 

Newsgroups
 


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