Solved

Access Form -no spaces

Posted on 2014-04-24
2
329 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
My experience with Windows 10 over a one year period and suggestions for smooth operation
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

911 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

18 Experts available now in Live!

Get 1:1 Help Now