By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,675 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Date Update!

P: n/a
I can't out figure what I've missed out or done wrong!! I have a
database which has a 'Last Update' field. This field has a general of
Short date & Default Value: Date(), which works well when a new record
is input, but when that record is updated by a user, say the next day,
the date isn't changing to the new date. I have tried with the
Default value as Now() and even created a new field for this to see if
there is any change, but nothing is changes.

Can anybody please throw some light on as to how I can get the date to
change to the date data is changed??

Thank you in advance

Trish
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Access cannot do this at the table level.

However, if your updates are made through a form, you can use the
BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![Last Update] = Now()
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"TrisH" <Tr**********@yahoo.co.uk> wrote in message
news:de************************@posting.google.com ...
I can't out figure what I've missed out or done wrong!! I have a
database which has a 'Last Update' field. This field has a general of
Short date & Default Value: Date(), which works well when a new record
is input, but when that record is updated by a user, say the next day,
the date isn't changing to the new date. I have tried with the
Default value as Now() and even created a new field for this to see if
there is any change, but nothing is changes.

Can anybody please throw some light on as to how I can get the date to
change to the date data is changed??

Thank you in advance

Trish

Nov 12 '05 #2

P: n/a
TrisH wrote:
I can't out figure what I've missed out or done wrong!! I have a
database which has a 'Last Update' field. This field has a general of
Short date & Default Value: Date(), which works well when a new record
is input, but when that record is updated by a user, say the next day,
the date isn't changing to the new date. I have tried with the
Default value as Now() and even created a new field for this to see if
there is any change, but nothing is changes.


DefaultValue applies only when the record is newly created. And since
Access (or Jet, the database engine) does not provide triggers, that is
some procedures that run on certain table events, you cannot fully have
this.

However, if all your table manipulation by users is through forms, you
can use the AfterUpdate event of the form to set the date field.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #3

P: n/a
Allen Browne wrote:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![Last Update] = Now()
End Sub


Aw, I said AfterUpdate, but that is bound to fail...

Addition: you can shake the square brackets if you don't use spaces in
object(field, table, form, query, report...) names.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #4

P: n/a
Bas Cost Budde <ba*@heuveltop.org> wrote in news:c055r9$umj$5
@news2.solcon.nl:
Addition: you can shake the square brackets


Is this some Salvation Army ritual?

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #5

P: n/a
Lyle Fairfield wrote:
Addition: you can shake the square brackets


Is this some Salvation Army ritual?


No, but it can be seen with Morris dancers.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #6

P: n/a
Bas Cost Budde <ba*@heuveltop.org> wrote in message news:<c0**********@news2.solcon.nl>...
Allen Browne wrote:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![Last Update] = Now()
End Sub


Aw, I said AfterUpdate, but that is bound to fail...

Addition: you can shake the square brackets if you don't use spaces in
object(field, table, form, query, report...) names.


I've tried the above, but it still isn't updating with both the before
update & after update. I have made a form for the table concerned,
but it's still not playing. Is the bit in brackets case sensitive?
Nov 12 '05 #7

P: n/a
TrisH wrote:
I've tried the above, but it still isn't updating with both the before
update & after update. I have made a form for the table concerned,
but it's still not playing. Is the bit in brackets case sensitive?


No, it isn't.
Please make sure the event really fires. You can set a breakpoint (press
F9 with the cursor on the =Now line) or put an extra line with MsgBox
"Hello" in the procedure; try editing; do you get at that spot?

If no: is the AfterUpdate (no, BeforeUpdate) *property* of the form set
to [Event Procedure]?
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.