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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recognize space at end of string

Status
Not open for further replies.
Jun 26, 2002
77
US
I have an error report that is used for spotting errors in data entry. One of the errors I am looking for is a space in a string field like first name. Everything works fine except if there is a space at the end of the field. Crystal is not recognizing that space. I have tried InStr and InStrRev and Right,1 etc. Does anyone know a formula that I can use to spot a space at the end of a string field?

Thank you,
Rose Mary
 
It may not be a space but some other non-printing character.

How about using
[tt]
left({field}, len{field}-1)
[/tt]
 
sorry, forgot the parentheses for Len [blush]
[tt]
Left({field}, Len({field})-1)
[/tt]
 
FYI: remblinrose is my co-worker. We are working with a odd database (cloud based). If we just bring in the table, the ODBC apparently strips off the blank on the end of a field (normally I would be happy with this), but if you use a command, it does not. But we are looking for data entry errors, thus we need to see if there is a blank at end of the field. Anyhow by using string functions in a command we were able achieve our goals.
 
Well then you need a more complex formula to determine if the last character is a display character or not.

If not, does it make a difference if the last non-display character is a SPACE or some other non-display character?
 
Right now we are looking for a space and the formula that we came up works just fine, something like this (NMS-SQL statement)
CASE WHEN ASCII*RIGHT({field},1)) = 32 THEN 'Yes' ELSE 'No' END. This is one of several 'flags' that they are using to try to catch data entry issues.
 
The is no "IsAlpha" but you can fake it like this:

if asc(right({table.field},1)) in 65 to 90
then 'Good'
else 'Bad'

This if for uppercase letters only.
If you also have lowercase letters then change the last part of the first line to: in [65 to 90, 97 to 122]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top