I’ve struck a nasty but small problem with text boxes. Via accident one of my clients is ending up with embedded cr/lf’s in a text box. This causes all sorts of drama when printing and when exporting to txt.
I know I could write a function to flatten the cr/lf, or add code to before update. But is there an easier way? Am I missing a ‘multi line’ True/false property that I just can’t see? Maybe there’s an input mask that will do it? (I’ve got the ‘Enter key behaivour’ as default, not new line in field) I feel like I missing something very simple.
Thanks for your help
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Stopping cr/lf in text box (Access 2000 SR1)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Stopping cr/lf in text box (Access 2000 SR1)
- This topic has 7 replies, 3 voices, and was last updated 21 years, 3 months ago.
AuthorTopicWSpeterl
AskWoody LoungerFebruary 24, 2004 at 4:26 am #401282Viewing 2 reply threadsAuthorReplies-
WScharlotte
AskWoody Lounger -
WSMarkLiquorman
AskWoody LoungerFebruary 24, 2004 at 2:48 pm #789503There is the “Enter Key Behavior” property for text controls which deals with how to handle when user just hits the Enter key rather than Tab. But as Charlotte mentioned, the Ctl+Enter is still a problem. Here is the abbreviated code I use to find this:
If InStr(txtsomething, vbCrLf) > 0 Then
msgbox “Invalid carriage return detected!”,vbcritical
Cancel=True
end ifYou can put this in your control’s BeforeUpdate event, or create a more generic function call that includes it.
-
WSpeterl
AskWoody LoungerFebruary 24, 2004 at 8:46 pm #789718Thanks for your help.
Just a note that this is a problem not just for when the user does a Ctrl-Enter. It also appears when the user pastes some info into the text box from somewhere else (for example Word), and that data has embedded Cr/Lf’s.
One more thing to go on my wish list for Access.
Peter -
WScharlotte
AskWoody LoungerFebruary 25, 2004 at 3:36 am #789865Non-printing characters pasted in from another application are always a problem. If that’s the way they’re coming in, then nothing in the form is going to stop them from getting into the field, although you could use the BeforeUpdate event of the form to scrub the memo field. You would have to check for more than just vbCRLF, though, because if they’re pasting from Word, they can bring in a lot of other non-printing characters in addition to the carriage return. Here’s a snippet I’ve used for that purpose:
If InStr(CStr(varItem), vbNewLine) > 0 Then
varItem = Replace(CStr(varItem), vbNewLine, “, “)
End If
If InStr(CStr(varItem), vbCr) > 0 Then
varItem = Replace(CStr(varItem), vbCr, “, “)
End If
If InStr(CStr(varItem), vbLf) > 0 Then
varItem = Replace(CStr(varItem), vbLf, “, “)
End If -
WScharlotte
AskWoody LoungerFebruary 25, 2004 at 3:36 am #789866Non-printing characters pasted in from another application are always a problem. If that’s the way they’re coming in, then nothing in the form is going to stop them from getting into the field, although you could use the BeforeUpdate event of the form to scrub the memo field. You would have to check for more than just vbCRLF, though, because if they’re pasting from Word, they can bring in a lot of other non-printing characters in addition to the carriage return. Here’s a snippet I’ve used for that purpose:
If InStr(CStr(varItem), vbNewLine) > 0 Then
varItem = Replace(CStr(varItem), vbNewLine, “, “)
End If
If InStr(CStr(varItem), vbCr) > 0 Then
varItem = Replace(CStr(varItem), vbCr, “, “)
End If
If InStr(CStr(varItem), vbLf) > 0 Then
varItem = Replace(CStr(varItem), vbLf, “, “)
End If
-
-
-
WSpeterl
AskWoody LoungerFebruary 24, 2004 at 8:46 pm #789719Thanks for your help.
Just a note that this is a problem not just for when the user does a Ctrl-Enter. It also appears when the user pastes some info into the text box from somewhere else (for example Word), and that data has embedded Cr/Lf’s.
One more thing to go on my wish list for Access.
Peter
WSMarkLiquorman
AskWoody LoungerFebruary 24, 2004 at 2:48 pm #789504There is the “Enter Key Behavior” property for text controls which deals with how to handle when user just hits the Enter key rather than Tab. But as Charlotte mentioned, the Ctl+Enter is still a problem. Here is the abbreviated code I use to find this:
If InStr(txtsomething, vbCrLf) > 0 Then
msgbox “Invalid carriage return detected!”,vbcritical
Cancel=True
end ifYou can put this in your control’s BeforeUpdate event, or create a more generic function call that includes it.
Viewing 2 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
4 hours, 19 minutes ago -
June KB5060842 update broke DHCP server service
by
Alex5723
2 hours, 51 minutes ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
6 hours, 54 minutes ago -
Excessive security alerts
by
WSSebastian42
2 hours, 35 minutes ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
16 hours, 22 minutes ago -
Ben’s excellent adventure with Linux
by
Ben Myers
32 minutes ago -
Seconds are back in Windows 10!
by
Susan Bradley
3 hours, 31 minutes ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
13 hours, 25 minutes ago -
OS news from WWDC 2025
by
Will Fastie
17 hours, 36 minutes ago -
Need help with graphics…
by
WSBatBytes
53 minutes ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
1 day, 7 hours ago -
Totally remove or disable BitLocker
by
CWBillow
6 hours, 58 minutes ago -
Windows 10 gets 6 years of ESU?
by
n0ads
10 hours, 13 minutes ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
1 day, 18 hours ago -
Search Forums only bring up my posts?
by
Deo
1 day, 18 hours ago -
Windows Spotlight broken on Enterprise and Pro for Workstations?
by
steeviebops
2 days, 6 hours ago -
Denmark wants to dump Microsoft for Linux + LibreOffice
by
Alex5723
1 day, 22 hours ago -
How to get Microsoft Defender to honor Group Policy Setting
by
Ralph
2 days, 6 hours ago -
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
2 days, 17 hours ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
2 days, 18 hours ago -
Disengage Bitlocker
by
CWBillow
2 days, 8 hours ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
2 days, 20 hours ago -
New Win 11 Pro Geekom Setup questions
by
Deo
1 day, 18 hours ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
3 days, 3 hours ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
3 days, 3 hours ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
3 days, 7 hours ago -
New PC transfer program recommendations?
by
DaveBoston
1 day, 12 hours ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
3 days, 11 hours ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
3 days, 11 hours ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
2 days, 23 hours ago
Recent blog posts
- Ben’s excellent adventure with Linux
- Seconds are back in Windows 10!
- WebBrowserPassView — Take inventory of your stored passwords
- OS news from WWDC 2025
- Best tools for upgrading a Windows 10 to an 11
- Master patch listing for June 10, 2025
- 24H2 may not be offered June updates
- June 2025 updates are out
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.