Solved

Access Form -no spaces

Posted on 2014-04-24
2
326 Views
Last Modified: 2014-04-25
Hello All,

I have users fill several tables via forms. Now when they are entering fieldA, - they cant enter words with spaces in them - for example:

good boy - not allowed

goodboy - allowed

how do i do that vba event to control that restriction

Rayne
0
Comment
Question by:Rayne
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40022133
Are users allowed to enter ONLY a single word in the area you want to control? Or can they enter free form text?

If they can only enter a single word, then you could simply use the BeforeUpdate event of that control to validate it:
Sub MyControl_BeforeUpdate(Cancel As Integer)
  If Instr(1, Me.MyControl.Text, " ") > 0 Then
    Msgbox "You cannot enter spaces"
    Cancel = True
  End If
End Sub

Open in new window

If you allow free form text, then I don't see how you could control that unless you can come up with a listing of accepted (or rejected) words. You could then compare each two-word combo to that and reject any that are found. I can see a LOT of trouble with that, however.
0
 

Author Closing Comment

by:Rayne
ID: 40023287
Thank you Scott :)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now