Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Left function : #error

Author  Topic 

vgunas1
Starting Member

18 Posts

Posted - 2003-05-16 : 11:49:38
I have the following query:
SELECT (Left([First Last],InStr([First Last],"/")-1)) AS Expr1
FROM Table1;
The First Last field looks like Louisa Alcott/IT/US. So I use this query to display it as Louisa Alcott.
The problem is that some of the records in the First Last field do not have the slash / or are empty. If the query executes it gives me #Error for those records.

If the records do not have a / or are empty for the First Last fieldI want Expr1 to be the same as First Last.

For eg:
If First Last is Louisa Alcott then I want the query to return Louisa Alcott. If it is Louisa Alcott/IT/US I want the query to give me Louisa Alcott.
Can anyone tell me how I can achieve them in the same query?

Thanks!:)

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-05-16 : 12:17:00
Read about the IIF() function see if you can come up with the answer....

(check Access help or any access book).

If you give up, let me know. But the answer is using that function ....

- Jeff
Go to Top of Page

vgunas1
Starting Member

18 Posts

Posted - 2003-05-16 : 12:26:14
The IFF function worked! Thanks a lot for your help!:)

Go to Top of Page
   

- Advertisement -