datetime stamp

A

Alison

Sorry for my ambiguity...I would like to have a datetime
stamp on a form that represents the last time any record
in one specific table was edited so that when that form
opens I can compare it with another copy of the mdb. I am
unable to use replication hence my need to ensure latest
copy and I thought this was a simple way to do it. I guess
the latest edit to anything may be useful also...?

Does code already exist for this?
thanks
Alison
 
D

Dirk Goldgar

Alison said:
Sorry for my ambiguity...I would like to have a datetime
stamp on a form that represents the last time any record
in one specific table was edited so that when that form
opens I can compare it with another copy of the mdb. I am
unable to use replication hence my need to ensure latest
copy and I thought this was a simple way to do it. I guess
the latest edit to anything may be useful also...?

Does code already exist for this?
thanks
Alison

In the future, to continue a discussion please reply to a message in the
existing discussion thread, rather than starting a new thread.
Otherwise, your correspondents may overlook your reply, as I almost did.

To do what you want, you first need to have a LastModified field defined
for the table that will hold the date/time each record was last
modified. Create such a field in the table's design view, and set its
DefaultValue property to Now(). Then on any form that edits this table,
have an event procedure for the form's BeforeUpdate event that will
again set the LastModified field to Now(). It might look like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)

' Note: if canceling the update, don't do this next line.
Me.LastModified = Now()

End Sub

Okay, once you've got this date-stamping working, you can have a text
box on your form that uses the DMax function to display the latest
(i.e., maximum) date in the table. The ControlSource property for the
text box would be something like this:

=DMax("LastModified", "YourTableName")

(where, of course, you would substitute the real table's name -- in
quotes -- for "YourTableName").
 
G

Guest

Dear Dirk
thanks for your help but I don't seem to understand... I
have modified the table and added a field called
lastmodified, made it a datetime field and made the
default = Now(), hence when I add new records this field
is filled. So now I just need the form to fill that field
when i edit any record - this is my problem. I have added
the before update event in the forms properties but I must
have something wrong... am i dealing with the textbox or
the field here? hope my question makes sence
thanks
alison
 

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

Similar Threads

datetime stamp on form when table edited 1
Date Stamp 5
Return a date from a datetime 2
Time Stamp 3
auto add a datetime stamp record 3
save new record with one form 9
DateTime InputMask 1
Access Cannot select items in listbox 1

Top