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