Date/Time stamp in Memo Field

P

Peter

Hi all..is it possible to programmatically insert Now() when text in a Memo
field becomes edited?

Thanks for all help!
 
L

Linq Adams via AccessMonster.com

If it has to be entered directly in the memo field tetxbox:

Private Sub MemoFieldName_AfterUpdate()
If IsNull(Me.MemoFieldName.OldValue) Then
Me.MemoFieldName = Now & " " & Me.MemoFieldName
Else
Me.MemoFieldName = Left(Me.MemoFieldName, Len(Me.MemoFieldName.OldValue)) &
" " & Now & " " & Right(Me.MemoFieldName, Len(Me.MemoFieldName) - Len(Me.
MemoFieldName.OldValue))
End If
Me.Dirty = False
End Sub

For this to work correctly, in case the user enters data in the memo field,
then, before leaving the record, enters more data in the memo field, the
record has to be saved after the date/time is inserted. Hence the line

Me.Dirty = False

Working with medical/legal records, where once an entry is made it cannot be
edited, I prefer to use another method. In this hack a second, unbound
textbox (TempDataBox) is used to enter the data into. This textbox is
originally hidden, and when the command button (IndirectDataInput) is clicked,
it appears. Data is entered, and when the command button (now captioned
“Commit Dataâ€) is clicked again, the entered data is added to the memo field.


Now, in this example, there are two memo fields, but only one is bound, since
the other memo field is simply a temporary holding area. The memo field is
also locked so that all data entry has to be done thru the temporary textbox.

TempDataBox is unbound, and in the Property Box its Visible Property is set
originally set to No. I place mine side by side with CommentsField so the
user can refer to what's currently in the CommentsField section while
entering new notes.

CommentsField is bound to the underlying table/query, and its Locked Property
is set to Yes.

Place a command button on the form. Name it IndirectDataInput and in the
Properties Box set its Caption to “Add New Data.â€

Now use this code:

Private Sub IndirectDataInput_Click()
If IndirectDataInput.Caption = "Add New Data" Then
TempDataBox.Visible = True
TempDataBox.SetFocus
IndirectDataInput.Caption = "Commit Data"
Else
IndirectDataInput.Caption = "Add New Data"
If IsNull(Me.CommentsField) Then
If Len(Me.TempDataBox) > 0 Then
Me.CommentsField = Now() & " " & Me.TempDataBox
Me.TempDataBox = ""
TempDataBox.Visible = False
Else
TempDataBox.Visible = False
End If
Else
If Len(Me.TempDataBox) > 0 Then
Me.CommentsField = Me.CommentsField & vbNewLine & Now() & " " & Me.
TempDataBox
Me.TempDataBox = ""
TempDataBox.Visible = False
Else
TempDataBox.Visible = False
End If

End If
End If
End Sub
 
J

Jeff Boyce

Peter

Is this because you are entering a single bit of text and want a date/time
stamp, or are you trying to stuff multiple notes into one Memo field, each
one date/time stamped?

(hint: if the latter, look into using a Notes table instead...)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
P

Peter

Thank you so much Ling and Jeff..this is very usefull. Yes i enter new notes
each time i edit the record resulting in a long string of notes in one memo
field. I am also using the FoSUsername module in the main record..i suppose i
can use it inthe memo field as well..?

Once again..thanks a lot!
 
J

Jeff Boyce

Peter

Memo fields carry their own special needs...

If you need/want a set of notes, date/time stamped, consider creating a
notes table with NoteDate and Note fields (and I would add NoteBy to capture
the person leaving the note).

Good luck!

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
J

James Brazelton

Sorry, I know I'm resurrecting an old thread, but I tried to use the
code you mention and I had some problems with it. When I use:

Private Sub MemoFieldName_AfterUpdate()
If IsNull(Me.MemoFieldName.OldValue) Then
Me.MemoFieldName = Now & " " & Me.MemoFieldName
Else
Me.MemoFieldName = Left(Me.MemoFieldName, Len
(Me.MemoFieldName.OldValue)) &
" " & Now & " " & Right(Me.MemoFieldName, Len(Me.MemoFieldName) - Len
(Me.
MemoFieldName.OldValue))
End If
Me.Dirty = False
End Sub

The problem I have is as you mention: If I want to edit the memo field
after I've entered something, I have to close the form and then reopen
it. Otherwise, when I try to edit it, I get an error. Is there any way
around this?
 

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