Form_Update event (Before or After)

M

Mohammad HABIB

Hi

I used a date field that should automatically update as of NOW() when update/change any objects on the form. But it is not working as I expect, when I open the form it update the date field as of NOW() even if I don't do anything on the form objects. I used Form_BeforeUpdate event for the form. I try to get Form_AfterUpdate event which give me message "you entered an expression that has an invalid reference to the property".

I linked references :
1. VB for Application
2. MS Access 11.0 object library
3. MS DAO 3.6 object library
4. MS Activex Data Object 2.8 library
5. OLE Automation

What should I do! Should I need any more reference link for this purpose! I need this updated date field to track the record status.


I appreciate your kind cooperation in advance.

regards

Habib

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
 
G

Gina Whipp

Mohammad,

I put it here...

Private Sub Form_Dirty(Cancel As Integer)
Me.DateFieldYouWantModified = Now()
End Sub
 
T

Tom van Stiphout

On Wed, 07 Jan 2009 19:25:20 -0800, Mohammad HABIB wrote:

This is most likely not a References problem.

You say that the date field updates when you open the form. I am
assuming you don't want that. You need to find the code that makes
that happen. If I had to debug that I would look in the Form_Open,
Form_Load, and Form_Current event. Also check the control properties:
you could have an expression in the <date_control>.ControlSource.

To check if the Form_BeforeUpdate code works, set a breakpoint and
step through.

-Tom.
Microsoft Access MVP
 
R

Rick Brandt

Hi

I used a date field that should automatically update as of NOW() when
update/change any objects on the form. But it is not working as I
expect, when I open the form it update the date field as of NOW() even
if I don't do anything on the form objects. I used Form_BeforeUpdate
event for the form. I try to get Form_AfterUpdate event which give me
message "you entered an expression that has an invalid reference to the
property".

I linked references :
1. VB for Application
2. MS Access 11.0 object library
3. MS DAO 3.6 object library
4. MS Activex Data Object 2.8 library 5. OLE Automation

What should I do! Should I need any more reference link for this
purpose! I need this updated date field to track the record status.


I appreciate your kind cooperation in advance.

BeforeUpdate is the best event for this. Are you sure you didn't also
set a DefaultValue for that field in the table or for the control on the
form? In that case the BeforeUpdate code will still work. It will just
replace the default value when you save.
 

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