Private Sub cmdSaveRecord_Click()
On Error GoTo cmdSaveRecord_Click_Err
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
Me.tboDescription = Me.tboDescription & vbNewLine & Now() & " " &
Me.tboFollowUp
Me.tboModifyDate = Now()
Me.Requery
cmdSaveRecord_Click_Exit:
Exit Sub
cmdSaveRecord_Click_Err:
MsgBox Error$
Resume cmdSaveRecord_Click_Exit
End Sub
The issue is adding vbNewLine to the control bound to a memo field. It only
adds a space between the old tboDescription.
When I don’t use vbNewLine I’ll get:
Boat sank
1/5/2010 4:30:01 PM Sank again1/5/2010 4:30:03 PM Sank again1/5/2010 4:30:06
PM Sank again1/5/2010 4:30:07 PM Sank again1/5/2010 4:30:08 PM Sank
again1/5/2010 4:30:09 PM Sank again
i.e. – Using vbNewLine I’ll get.
Boat sank
1/5/2010 4:30:01 PM Sank again 1/5/2010 4:30:03 PM Sank again 1/5/2010
4:30:06 PM Sank again 1/5/2010 4:30:07 PM Sank again 1/5/2010 4:30:08 PM Sank
again 1/5/2010 4:30:09 PM Sank again
When I’m looking for:
Boat sank
1/5/2010 4:30:01 PM Sank again
1/5/2010 4:30:03 PM Sank again
1/5/2010 4:30:06 PM Sank again
1/5/2010 4:30:07 PM Sank again
1/5/2010 4:30:08 PM Sank again
1/5/2010 4:30:09 PM Sank again
I have also tried the following with no success.
Me.tboDescription = Me.tboDescription & (Chr(13) + Chr(10)) & Now() & " " &
Me.tboFollowUp
Me.tboDescription = Me.tboDescription & Chr(13) & Chr(10) & Now() & " " &
Me.tboFollowUp
This also happens if the record source is a table instead of a query.
Is there some sort of “Advanced customization option for Access” that needs
to be set a certain way for vbNewLine to work? Is this a control “Text
Format” issue?
Secondary question:
Is there any way to display Chr(13) + Chr(10) type codes in a control bound
to a memo field?
As always, any help on this is greatly appreciated.
Try setting the TextFormat property of the textbox to "Rich Text".
Chr(13) + Chr(10) can also be written as vbCrLf.
-Tom.
Microsoft Access MVP