Line return from string to Field (1 Viewer)

pekajo

Registered User.
Local time
Today, 21:13
Joined
Jul 25, 2011
Messages
132
Hi,
It's me again.
I need to add a line feed in a string and write to a field. It works if I use msgbox but not when I write to the field.
I have tried all the normal chr(10) and chr(13) and both together.

I have the following code:
If IsNull(Me.D1AM) Then

Me.D1AM = DLookup("[Given]", "Volunteers", "[ID] = " & Me.Combo14)
Else
Me.D1AM = Me.D1AM & Chr(10) & DLookup("[Given]", "Volunteers", "[ID] = " & Me.Combo14)
End If
aa = Me.D1AM + vbNewLine & DLookup("[Given]", "Volunteers", "[ID] = " & Me.Combo14)

Thanks
Peter
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:13
Joined
May 7, 2009
Messages
19,169
can you try using vbCrLf instead of vbNewLine:



aa = Me.D1AM + vbCrLf & DLookup("[Given]", "Volunteers", "[ID] = " & Me.Combo14)
 

isladogs

MVP / VIP
Local time
Today, 10:13
Joined
Jan 14, 2017
Messages
18,186
I use vbCrLf or vbNewLine with the & operator ...not the + operator
 

Darrylles

New member
Local time
Today, 10:13
Joined
Nov 23, 2015
Messages
2
Not sure, but it all depends on the receiving field data-type.

aa = Me.D1AM + vbNewLine & DLookup("[Given]", "Volunteers", "[ID] = " & Me.Combo14)

This seems to be passing a STRING value.

I'd use:

aa = Me.D1AM & vbCRLF & "'" & DLookup("[Given]", "Volunteers", "[ID] = " & Me.Combo14) & "'"

Surrounding the whole, passed value in quotes.

Try it.

ATB,

Darrylle
 

Micron

AWF VIP
Local time
Today, 06:13
Joined
Oct 20, 2018
Messages
3,476
As a side note, if you ever need to use chr for this, it has to be both chr(13) and chr(10) and in that order.
 

Users who are viewing this thread

Top Bottom