Time Stamp in a Memo Field

T

Timothy Millar

I have a form. Within that forms' properties I have the following Event
Procedure listed under On Enter in the Event tab;

Private Sub LOGUPDATE_Enter()
Me!LOGUPDATE.SelStart = Me!LOGUPDATE.SelLength
End Sub

This simply places the cursor at the end of any text that may be in the MEMO
field entitled “LOGUPDATEâ€. What I want to do is place a date/time stamp
after this command so that if there is no text in the MEMO field then the
date/time is entered and if there is text it will place the date/time after
that text but I am not sure how to do this. Can anyone help me?
 
D

Douglas J. Steele

Private Sub LOGUPDATE_Enter()

Me!LOGUPDATE = Me!LOGUPDATE & Now()
Me!LOGUPDATE.SelStart = Me!LOGUPDATE.SelLength
End Sub
 
T

Timothy Millar

That helped out perfectly. Is there a way to enter in a hard return before
the date/time stamp if there is content in the field and no hard return if
the field is blank?
 
D

Douglas J. Steele

Private Sub LOGUPDATE_Enter()
Me!LOGUPDATE = (Me!LOGUPDATE + vbCrLf) & Now()
Me!LOGUPDATE.SelStart = Me!LOGUPDATE.SelLength
End Sub

This takes advantage of the fact that + and & have different behaviours when
used as string concatenation characters. + propagates Nulls, while &
doesn't. In other words, "anything" + Null results in Null, while "anything"
& Null results in "anything"
 
D

David W. Fenton

=?Utf-8?B?VGltb3RoeSBNaWxsYXI=?=
What I want to do is place a date/time stamp
after this command so that if there is no text in the MEMO field
then the date/time is entered and if there is text it will place
the date/time after that text but I am not sure how to do this.

It sounds to me as though you have a design error. You are storing
in a single memo field idividual pieces of data that ought be in
individual records in a related table.
 

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