473,395 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Forcing a New Line in a Text Field in MS Access using VB

Heya!

I feel I'm beating an old horse to death with this question but I
can't get around the problem.

I want to update a text field on a form with a string from a VB
module. I need enter/linefeeds in the string.

I've tried:
Chr(10) & Chr(13)
Chr(13) & Chr(10
vbnewline
vbcrlf
none of which seem to work.
I've set the properties for the text box to [Enter Key Behavior] =
'New Line In Field' and [Can Grow] = 'yes'.

At the moment, my code looks like this:
celsql = celsql _
& "Program: " & encname _
& vbCrLf _
& vbCrLf _
& "Start Time: " & sttim _
& vbCrLf _
& "Participants: " & numpart _
& vbCrLf _
& "Confirmed by Curator: " & cbc _
& vbCrLf _
& "Client: " & clntnm _
& vbCrLf _
& "Contact: " & cntct _
& vbCrLf _
& vbCrLf
Forms(frm)(bts) = celsql

If I toss this string into a [MsgBox], it comes out fine. It's just
something about the text field...

I'm working in MSAccess 2007, but need it backwards compatible to
2003.

I'd really appreciate any advice.

Cheers,
KG
Nov 19 '07 #1
5 10965
I've seen this type of problem before, but I typically just use a
separate text box for each data field. Is there a particular reason
why you're trying to fit this all into a single text box?
Nov 19 '07 #2
Thanks for asking! It's a long story :)

I've used unbound Access forms backed by a fair bit of VB code to
generate interactive calendars. Each textbox is the cell for a given
date. The program updates information into the cell for one or more
[event]s occurring on that date. Each [event] is comprised of the text
string above. Users print off the calendars to post around the
workplace. Since there can be more than one [event] per text box
(day), I can't easily use multiple text boxes (although it would be
possible).

I know I'm pushing the edge of what Access can cope with and am likely
better off creating interactive calendars from scratch using VB. If
there's no easy patch or solution, I'll look for some other way to do
it. I was thinking maybe I had the wrong [References] selected?

Thanks for the help!

KG :)
Nov 20 '07 #3
On Nov 19, 11:52 am, Bubo.virginia...@gmail.com wrote:
Heya!

I feel I'm beating an old horse to death with this question but I
can't get around the problem.

I want to update a text field on a form with a string from a VB
module. I need enter/linefeeds in the string.

I've tried:
Chr(10) & Chr(13)
Chr(13) & Chr(10
vbnewline
vbcrlf
none of which seem to work.
I've set the properties for the text box to [Enter Key Behavior] =
'New Line In Field' and [Can Grow] = 'yes'.

At the moment, my code looks like this:
celsql = celsql _
& "Program: " & encname _
& vbCrLf _
& vbCrLf _
& "Start Time: " & sttim _
& vbCrLf _
& "Participants: " & numpart _
& vbCrLf _
& "Confirmed by Curator: " & cbc _
& vbCrLf _
& "Client: " & clntnm _
& vbCrLf _
& "Contact: " & cntct _
& vbCrLf _
& vbCrLf
Forms(frm)(bts) = celsql

If I toss this string into a [MsgBox], it comes out fine. It's just
something about the text field...

I'm working in MSAccess 2007, but need it backwards compatible to
2003.

I'd really appreciate any advice.

Cheers,
KG
This works for me in Access 2007 (that is the line breaks are shown):

Private Sub Command38_Click()
Me.Notes.Value = "Education includes a BA in psychology from Colorado
State University in 1970." _
& vbNewLine _
& "She also completed 'The Art of the Cold Call.'" _
& vbNewLine _
& "Nancy is a member of Toastmasters International."
End Sub

The textbox shows:

Education includes a BA in psychology from Colorado State University
in 1970.
She also completed 'The Art of the Cold Call.'
Nancy is a member of Toastmasters International.
Nov 20 '07 #4
Bu**************@gmail.com wrote:
Heya!

I feel I'm beating an old horse to death with this question but I
can't get around the problem.

I want to update a text field on a form with a string from a VB
module. I need enter/linefeeds in the string.

I've tried:
Chr(10) & Chr(13)
Chr(13) & Chr(10
vbnewline
vbcrlf
none of which seem to work.
I've set the properties for the text box to [Enter Key Behavior] =
'New Line In Field' and [Can Grow] = 'yes'.

At the moment, my code looks like this:
celsql = celsql _
& "Program: " & encname _
& vbCrLf _
& vbCrLf _
& "Start Time: " & sttim _
& vbCrLf _
& "Participants: " & numpart _
& vbCrLf _
& "Confirmed by Curator: " & cbc _
& vbCrLf _
& "Client: " & clntnm _
& vbCrLf _
& "Contact: " & cntct _
& vbCrLf _
& vbCrLf
Forms(frm)(bts) = celsql

If I toss this string into a [MsgBox], it comes out fine. It's just
something about the text field...

I'm working in MSAccess 2007, but need it backwards compatible to
2003.

I'd really appreciate any advice.

Cheers,
KG
I created a form in A97 (not 2007, I know) with a TextBox and Command
button. The code below works just fine. I didn't bother with setting
grow props and I kept the keystrokes as default (IOW, not the enter
key). If it doesn't work, it might be an A2007 thing.

Now...I did not make this a bound field to a table. I'd use a Memo
field if that were the case. Are you using a Text field with a small
number of characters as its length?
Private Sub Command2_Click()
MsgBox Me.Text0
End Sub

Private Sub Form_Current()
s = "Program: " & "Is" _
& vbCrLf _
& vbCrLf _
& "Start Time: " & Now() _
& vbCrLf _
& "Participants: " & 1 _
& vbCrLf _
& "Confirmed by Curator: " & "Yes" _
& vbCrLf _
& "Client: " & "Customer" _
& vbCrLf _
& "Contact: " & "Client" _
& vbCrLf _
& vbCrLf
Forms("Form1")("Text0") = s
End Sub
Nov 20 '07 #5
I use Access 2000, but unless it's been changed since, the "Can Grow"
property only works when the form is printed (or previewed), not when it's on
the screen as a form. Check the help file for your version.

John

Bu**************@gmail.com wrote:
>Heya!

I feel I'm beating an old horse to death with this question but I
can't get around the problem.

I want to update a text field on a form with a string from a VB
module. I need enter/linefeeds in the string.

I've tried:
Chr(10) & Chr(13)
Chr(13) & Chr(10
vbnewline
vbcrlf
none of which seem to work.
I've set the properties for the text box to [Enter Key Behavior] =
'New Line In Field' and [Can Grow] = 'yes'.

At the moment, my code looks like this:
celsql = celsql _
& "Program: " & encname _
& vbCrLf _
& vbCrLf _
& "Start Time: " & sttim _
& vbCrLf _
& "Participants: " & numpart _
& vbCrLf _
& "Confirmed by Curator: " & cbc _
& vbCrLf _
& "Client: " & clntnm _
& vbCrLf _
& "Contact: " & cntct _
& vbCrLf _
& vbCrLf
Forms(frm)(bts) = celsql

If I toss this string into a [MsgBox], it comes out fine. It's just
something about the text field...

I'm working in MSAccess 2007, but need it backwards compatible to
2003.

I'd really appreciate any advice.

Cheers,
KG
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200711/1

Nov 20 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jamait | last post by:
Hi all, I m trying to read in a text file into a datatable... Not sure on how to split up the information though, regex or substrings...? sample: Col1 Col2 ...
1
by: Steve | last post by:
I have a form with 28 fields; 4 are comboboxes, 23 are textboxes and 1 is a memo field. Some fields may be left blank when entering a new record. After one or more new records are created, the...
4
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary...
1
by: Sami | last post by:
Title says it all. Using a Listbox to look up numbers - ie SSN for a student - and then all of a sudden it shows up as 2323E+08 instead of say 232-23-2323. Help! Also, how can I force zeroes...
6
by: Sami | last post by:
Problem: Social Security number being used in a database. First problem is that it will not permit numbers beginning in zero to be entered - it sees it as a null or empty space from what I can...
0
by: Darran Shelton | last post by:
Hi. I have a Class named Echo. That contains a private attribute Data, which is a dataset that contains a single table (T_Echo) that can have multiple records. I then have public properties, one...
2
by: JohnR | last post by:
When creating an msAccess db within the Access UI itself the fields that are text are NOT padded with blanks. For example, if I have a 10 char field and put in "HI" and then when I come back to...
2
by: alexsg | last post by:
I'm setting up a resolutions database where each resolution will be copied from Word documents and pasted into a memo field. The resolution will be in the form: Resolution title <cr> Project no...
1
by: camphor | last post by:
hi all, I have a webpage with just images and am using a liquid layout for my css, go to http://www.christinebec.com/About CB/selected_editorials.htm to see what I am talking about, after the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.