Forcing New Line in Text Box

Jonathan Kok

Registered User.
Local time
Today, 04:41
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?
 
Try:

[ordnotes] = [ordnotes] & vbNewLine & note

HTH
RDH
 
Thanks, it worked fine!
 
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:
 
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.
 
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?
 
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
 
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
 
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
 
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

Back
Top Bottom