Forcing New Line in Text Box (1 Viewer)

Jonathan Kok

Registered User.
Local time
Today, 11:39
Joined
Jan 27, 2000
Messages
116
I have a text box (based on a "Memo" Data Type Field), and I want multiple lines of information to be entered into it at the click of a button. But, it can't erase what's already in the text box; I want it to append to the end of the text as a new line in the same field. The current code is as follows:

dim note as string
note = "whatever"
[ordnotes] = [ordnotes] & chr$(13) & note

All I get is a funky character in the middle of what becomes a run-on sentence. WHY doesn't this work? How can I get it to work?
 

R. Hicks

AWF VIP
Local time
Today, 10:39
Joined
Dec 23, 1999
Messages
619
Try:

[ordnotes] = [ordnotes] & vbNewLine & note

HTH
RDH
 

Jonathan Kok

Registered User.
Local time
Today, 11:39
Joined
Jan 27, 2000
Messages
116
Thanks, it worked fine!
 

murray83

Games Collector
Local time
Today, 15:39
Joined
Mar 31, 2017
Messages
728
have searched for this and understand that this post is a few years old but it dont work for me as i have this so far

Code:
=DLookUp("[AM Shift]","[MTM]","[AM When] = [MTMDateAM] ")+DLookUp("[AM Shift1]","[MTM]","[AM When] = [MTMDateAM] ")

and it puts the text on one line but then when i put in as suggested
Code:
& vbNewLine &
all i get in my textbox #name

help appreciated

cheers all :cool:
 

Mark_

Longboard on the internet
Local time
Today, 08:39
Joined
Sep 12, 2017
Messages
2,111
Are you trying to change the computed field?

i.e. are you trying to add something to the field that has your DLookup in it? Or are you trying to update another field? Also, where are you putting your code? Also, what type of control are you updating?

For myself, I normally use chr(13) & chr(10) as I know exactly what I'm putting and where.
 

isladogs

MVP / VIP
Local time
Today, 15:39
Joined
Jan 14, 2017
Messages
18,186
Some more questions for you.
1. Do each of the DLookups give a result on their own?
2. When you add "& vbNewLine &", are you replacing the + with that?
 

murray83

Games Collector
Local time
Today, 15:39
Joined
Mar 31, 2017
Messages
728
Some more questions for you.
1. Do each of the DLookups give a result on their own?
2. When you add "& vbNewLine &", are you replacing the + with that?


1. Yes by them selves it would populate a text box with a result
2. No as when i do it faults saying #Name
 

murray83

Games Collector
Local time
Today, 15:39
Joined
Mar 31, 2017
Messages
728
Are you trying to change the computed field?

i.e. are you trying to add something to the field that has your DLookup in it? Or are you trying to update another field? Also, where are you putting your code? Also, what type of control are you updating?

For myself, I normally use chr(13) & chr(10) as I know exactly what I'm putting and where.

The control I am updating is a textbox and the code is in the control source for the text box

im trying to add from a second record in the table into the one text box as you cant have 3 sepreate things in one record
 

isladogs

MVP / VIP
Local time
Today, 15:39
Joined
Jan 14, 2017
Messages
18,186
1. Yes by them selves it would populate a text box with a result
2. No as when i do it faults saying #Name

2. You should never use both vbNewLine and +.
Whilst + works in certain cases when concatenating string, & always works.
If its failing when just using '& vbNewLine & ' you are doing something else wrong

Any of these should do what you want (with the quotes removed)
- ' & vbNewLine & '
- ' & vbCrLf & '
- ' & Chr(13) & Chr(10) & '
NOTE the & sign before and after, together with spaces

you cant have 3 separate things in one record

Actually you can - its called a multi value field - but DON'T - avoid like the plague....

HTH
 

murray83

Games Collector
Local time
Today, 15:39
Joined
Mar 31, 2017
Messages
728
2. You should never use both vbNewLine and +.
Whilst + works in certain cases when concatenating string, & always works.
If its failing when just using '& vbNewLine & ' you are doing something else wrong

Any of these should do what you want (with the quotes removed)
- ' & vbNewLine & '
- ' & vbCrLf & '
- ' & Chr(13) & Chr(10) & '
NOTE the & sign before and after, together with spaces



Actually you can - its called a multi value field - but DON'T - avoid like the plague....

HTH

Many Thanks the code
Code:
& Chr(13) & Chr(10) &
worked and this is now what i have and works fine

Code:
=DLookUp("[AM Shift]","[MTM]","[AM When] = [MTMDateAM] ") & Chr(13) & Chr(10) & DLookUp("[AM Shift1]","[MTM]","[AM When] = [MTMDateAM] ")

cheers all
 

Users who are viewing this thread

Top Bottom