ignore spaces

  • Thread starter Thread starter Rajtomar
  • Start date Start date
R

Rajtomar

Eg. I have all the courses numbered uniquely like first course of year
2008 course nam SMS will be given course no. 001SMS08 by the user. now
if the user enters 001 SMS 08 and saves the course number. Then some
else when queries about course no. 001SMS08 then it will not show any
result.
So how to ignore spaces typed (accidently) between characters in
the text field of a form save the value with all space removed in
between characters.
 
Eg. I have all the courses numbered uniquely like first course of year
2008 course nam SMS will be given course no. 001SMS08 by the user. now
if the user enters 001 SMS 08 and saves the course number. Then some
else when queries about course no. 001SMS08 then it will not show any
result.
So how to ignore spaces typed (accidently) between characters in
the text field of a form save the value with all space removed in
between characters.

Code the AfterUpdate event of the control on the form:
Me![ControlName] = Replace([ControlName]," ","")

Any spaces entered into the field will be removed.
 
Eg. I have all the courses numbered uniquely like first course of year
2008 course nam SMS will be given course no. 001SMS08 by the user. now
if the user enters 001 SMS 08 and saves the course number. Then some
else when queries about course no. 001SMS08 then it will not show any
result.
So how to ignore spaces typed (accidently) between characters in
the text field of a form save the value with all space removed in
between characters.

You can use the AfterUpdate event of a textbox to strip spaces:

Private Sub txtCourseNo_AfterUpdate()
Me!txtCourseNo = Replace(Me!txtCourseNo, " ", "")
End Sub

Or you can use an input mask which prohibits spaces from being typed (probably
less friendly for the user).
 
Back
Top