vbNewLine in memo field bound control

H

h2fcell

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.
 
T

Tom van Stiphout

On Tue, 5 Jan 2010 14:05:01 -0800, h2fcell

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
 

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