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

Counting characters in a string 1

Status
Not open for further replies.

cafenerogal

Technical User
Mar 23, 2004
12
GB
Help!

I'm trying to write a report that shows the forename, and surname for a person (along with other relevant data, which I already have sorted out).

The table (people) has 4 fields that may contain this information; Forename, Surname, Legal_forename, Legal_Surname.

If the Forename field only has a single character, then I need to check the Legal_forename field. If this is null, or contains a single characte, or matches the Forename field, then the Forename field needs to be displayed. If the Legal_forename field contains more than one character, then display the Legal_forename field.

Thanx
 
You will need to use the length function in an if-then-else statement. This should be something like this

if length(forename) = 1 then
if isnull(legal forename}) or length(legal forename) = 1 or length(legal forename}) = length(forename) then forename else
if length(legal forename) > 1 then legal forename

hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top