Date Update and

S

steve

I have the following very simple code in a BeforeUpdate Event
Procedure

Private Sub Date1_BeforeUpdate(Cancel As Integer)
Me!Date1 = Date
End Sub

I just want it to put the date in the field when someone changes the
data in the form.
However when I run it I get the following error. ( and no date
inserted into the field)

Run-time Error '2115'
The macro or function set to the BeforeUpdate or ValidationRule
property for this field is preventing the Employee Database v1 from
saving the data in the field.

I have searched for an answer to this and it seems people say that its
due to to the field being set in the table to "Allow Zero Length" No
But I have simply used the default settings that access sets up which
is Yes. The field is a text field but when I set it up to date field
it doesnt help. Can anyone point me to what I dont understand about
this.

Thanks.
 
R

Rick Brandt

steve said:
I have the following very simple code in a BeforeUpdate Event
Procedure

Private Sub Date1_BeforeUpdate(Cancel As Integer)
Me!Date1 = Date
End Sub

I just want it to put the date in the field when someone changes the
data in the form.
However when I run it I get the following error. ( and no date
inserted into the field)

Run-time Error '2115'
The macro or function set to the BeforeUpdate or ValidationRule
property for this field is preventing the Employee Database v1 from
saving the data in the field.

I have searched for an answer to this and it seems people say that its
due to to the field being set in the table to "Allow Zero Length" No
But I have simply used the default settings that access sets up which
is Yes. The field is a text field but when I set it up to date field
it doesnt help. Can anyone point me to what I dont understand about
this.

Thanks.

Use BeforeUpdate of the FORM, not the control you want to update.
 
S

steve

Ohhhhhhhh ....

That Works,

So why would it not work on that local field it "seems" like it
should, Why is this ??

Thanks.
 
R

Rick Brandt

steve said:
Ohhhhhhhh ....

That Works,

So why would it not work on that local field it "seems" like it
should, Why is this ??

Thanks.

In the BeforeUpdate event of a control you are trying to set the value of
that very same control. You don't see a problem with that logic?

Even if it worked the user is never going to update that control since you
want that to happen automatically anyway so the BeforeUpdate of the control
should never fire in the first place.
 

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