date stamp Can I add a date stamp in a Text or Memo Field

G

Guest

Can I add a date stamp (and or a User stamp) in a Text or Memo Field when a
user updates my notes field (Memo)
 
K

Ken Snell [MVP]

If you are asking, "can I concatenate the value of the current date and time
into a text field's contents" (or memo field's contents), the answer is yes.
 
G

Guest

Can you point me in the dircection of any examples or code that could help
me. Thanks,
 
K

Ken Snell [MVP]

In which context would you be doing this?

As an example, the following code step would add the current date and time
to a control on a form:

Me.ControlName.Value = Me.ControlName.Value & vbCrLf & _
Format(Now(), "dd mmm yyyy at hh:nn:ss ampm")
 
K

Ken Snell [MVP]

Note that the vbCrLf that I put in the code is not a requirement - I
included it only as a "separator" for the date/time stamp. Also, the Format
"format" ("dd mmm yyyy at hh:nn:ss ampm") that I provided can be changed to
other options.
 
J

John Vinson

On Mon, 4 Apr 2005 16:13:01 -0700, Michael L <Michael
Can I add a date stamp (and or a User stamp) in a Text or Memo Field when a
user updates my notes field (Memo)

As Ken says - you can; but you *shouldn't*. Fields should be atomic. A
text note and a timestamp are two different pieces of information!

Might you consider adding a Date/Time field (default value Now()) to
your table, so that when a record (including a note) is entered the
time that it was entered is automatically retained, just in a
different field?

John W. Vinson[MVP]
 
G

Guest

The Date/Time field with the Now() default works great for indicating when a
record is entered. But how would you implement a "Date Last Changed"
Date/Time field that would change to Now() whenever anything in the record is
changed? I suspect it might be based on the BeforeUpdate event but I can't
find anything on the actual mechanics of it.
 
J

John Vinson

The Date/Time field with the Now() default works great for indicating when a
record is entered. But how would you implement a "Date Last Changed"
Date/Time field that would change to Now() whenever anything in the record is
changed? I suspect it might be based on the BeforeUpdate event but I can't
find anything on the actual mechanics of it.

Quite correct. Something like this in the Form's BeforeUpdate:

Private Sub Form_BeforeUpdate(Cancel as Integer)
<put any validation code here, set Cancel to True and exit if there is
a validation error>
<if all is well...>
Me!DateLastChanged = Now
End Sub

John W. Vinson[MVP]
 
G

Guest

That worked fine. Thank you.

But suppose I go in and change something directly in a table without using a
form. Is there any way to ensure that the "Date Last Changed" field gets
updated then too?
 
R

Rick Brandt

mdavidjohnson said:
That worked fine. Thank you.

But suppose I go in and change something directly in a table without
using a form. Is there any way to ensure that the "Date Last Changed"
field gets updated then too?

Nope. Not unless you use a server database that supports triggers for the back
end.
 
J

John Vinson

But suppose I go in and change something directly in a table without using a
form. Is there any way to ensure that the "Date Last Changed" field gets
updated then too?

No.

John W. Vinson[MVP]
 

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