Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function to remove double spaces and strange characters

Status
Not open for further replies.

Aydan

Technical User
Dec 14, 2002
51
0
0
BE
Hi,
Is there anybody who has already a good function to correct typing errors in fields such as double spaces between words, a ° or ², or starting a field with a space. This typo's causes the records to be unfindable!


 
Hi Aydan

The best way to remove typos is to prevent the user from entering them! I always make the user select from a list if at all possible, select from an Option Group select from anywhere but don't let them type unless it isn't important.

With thought and careful design almost all user input can be predicted. Allow them to add to a list or use the current table as the rowsource of a combo then they see what others have done and it makes them more careful.
 
It wouldn't be too bad to create a library function that will do stuff like that - I've created a similar function so that someone can enter many different date formats into the box and it will properly recognize them. In the after_update event for the text box, have something like this:

[TextBox] = Lib.CheckText([TextBox])

Then in a module have the function CheckText look something like:


Public Function CheckText(strString As String) As String

Dim intCount As Integer
intCount = 0

Do Until intCount = Len(strString)
If chr(Mid(strString, intCount, 1)) < ...
.....


Look up an ascii table to find out what character values are invalid, which isn't bad because all the valid ones are basically sequential.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top