Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vbNewLine in memo field bound control

41 views
Skip to first unread message

h2fcell

unread,
Jan 5, 2010, 5:05:01 PM1/5/10
to
Hello I’m using Access 2007 and have read several posts regarding my issue.
I have a form that opens, based on a list box selection, using a query as
the Record Source.
The form has an update record button that has the following code:

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.

Tom van Stiphout

unread,
Jan 5, 2010, 9:14:17 PM1/5/10
to
On Tue, 5 Jan 2010 14:05:01 -0800, h2fcell
<h2f...@discussions.microsoft.com> wrote:

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

0 new messages