Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Recognize space in text box TRIM
harry mullin 
   
12 years ago
I have an unbound textbox control on the header of a continuous form. I use the On Change event to trigger code which grabs what ever is typed in to reset the forms RecordSource. (me.RecordSource = "SELECT * FROM ClientT WHERE Company like '*" & me.Findtxt & "*' ORDER BY Company"

Works fine unless user types a space. No matter what I do, the space is removed by the code before it can be used in the Select statement. Do you know a way around this?


Reply from Richard Rost:

Is the space before/after the text or within it? If it's outside, that sounds like a TRIM is running, which happens by default with most text boxes in Access - to prevent accidental spaces, like after a FirstName field. I don't know of a way to turn this behavior off. It's not in the AutoCorrect options (File > Options > Proofing).

I did a quick Google search and from what I can tell, there's no way around this (yeah, kinda lame, I agree). I would recommend selecting another character like _ and then teaching your users to use that to search for a space. In your code you could then say:

X = Me.FindTxt
X = Replace(X,"_"," ")

Then use X for your SQL where condition. I'll post this to my Access MVP email group and see if anyone on there has a better solution.

My email to them:

---

Hey guys.

I have a student who just asked me a great question: is it possible to STOP Access from trimming trailing spaces from a text box? I know that's generally the way you want Access to behave (to prevent first names like "Joe ") but in this particular case he's building a search form and he wants the option to have a trailing space in his search criteria. For example, he may want to search for "Jo " and not get values returned like "Joseph".

After some searching I can't find a way to turn this option off. It's not in the Autocorrect options, nor the properties for text boxes. I recommended for now just using an underscore and then REPLACE-ing that in code to a space character, but that's a cheesy solution.

Any thoughts?

---

I'll be sure to share any useful replies.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/15/2026 1:03:32 AM. PLT: 0s