473,395 Members | 1,530 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.

"no spaces" code on Access form

Hello,

I'm trying to find code to use in order to prohibit users from entering spaces into a field on a form in MS Access 07?

Any suggestions?

Thanks.
Barry
Jul 30 '10 #1
3 2090
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourTextBoxName_KeyDown(KeyCode As Integer, Shift As Integer)
  2.  If KeyCode = vbKeySpace Then
  3.   KeyCode = 0
  4.  Else
  5.   KeyCode = KeyCode
  6.  End If
  7. End Sub
Welcome to Bytes!

Linq ;0)>
Jul 30 '10 #2
OldBirdman
675 512MB
That works if entry is by individual keys. It will fail with Copy/Paste.
I don't know if replacing all the blanks (" ") with zero-length strings ("") will be OK, but that could be done on the BeforeUpdate of the control.
Jul 30 '10 #3
NeoPa
32,556 Expert Mod 16PB
I don't think there's a really satisfactory way of doing it I'm afraid.

The InputMask options don't seem to cover that. The KeyDown suffers from being open to Pasting. The BeforeUpdate allows the data to be typed, even if it doesn't allow for the character to be passed to the underlying field. I would suggest the Change event procedure to catch each character entered and use (as suggested by OB) :
Expand|Select|Wrap|Line Numbers
  1. Private Sub XXX_Change()
  2.     Me.XXX = Replace(Me.XXX, " ", "")
  3. End Sub
Jul 31 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and...
2
by: Jason Huang | last post by:
Hi, Kind of spending too much time on the no-cache issue and found out something like <% Response.CacheControl = "no-cache" %>. In my ASP.Net, a C# .aspx file, where do I put the <%...
3
by: Andy Fish | last post by:
Hi, when there are no rows to display in my asp.net datagrid control, I'd like to put in a message saying "No results" or some such Ideally I'd like the message to be centred across all the...
1
by: Edward King | last post by:
I have a statement in a asp,like follows£º var str=window.top.main.document.all.contenttext.value; I use IIS5.0 to deploy this asp,then I visit this asp like follows:...
1
by: D.M. | last post by:
Hi, One of the people here at work has designed a database that students will be using to enter data. She has Yes/No selection buttons, which start out grayed out with no value. If a student...
7
by: dongdong | last post by:
using web browser can get page's content formally, but when use urllib2.open("http://tech.163.com/2004w11/12732/2004w11_1100059465339.html").read() the result is <html><head><META...
1
by: pbd22 | last post by:
hi. for some reason i am not able to navigate the dom. i keep getting the 'no properties' error but i think i am doing everything right. this is an XML response from an AJAX call. The ajax...
3
by: prljng | last post by:
Can anyone tell me how to report "no data" in an Access report? When a field value in the detail section is null, I want to have text that says 'No results for this group header'.
7
JustJim
by: JustJim | last post by:
Just when I thought I was getting my head around Null values.... I have a report with three sub-reports, on each sub-report footer I count how many records in the subreport. No problemo. On...
0
by: serhii7777 | last post by:
Hi, I have a report, which includes several subreports based on specific queries. Sometimes, one of the queries returns no result, which leaves a blank spot on a report. Is there a way to put a...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.