ignore spaces

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.
 
F

fredg

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.
 
J

John W. Vinson

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top