Equivalent Excel =Search for MS Access

W

wooster

Hi,
I'm trying to reproduce the following (ignore the iserror stuff):
=IF(ISERROR(LEFT(G2,SEARCH(" ",G2,1))),G2,LEFT(G2,SEARCH(" ",G2,1)-1))

Basically I need to find the first occurence of a space, which will be
the end of a string of First Names, eg. Fleur Annabel and return just
the first name eg. Fleur.

I can't find an equivalent Search function in MS Access.

Many thanks

Wendy
 
D

Douglas J. Steele

The IIf function in Access is essentially the same as the If function in
Excel (there is a difference in how you string conditions together: you do
not need the And or Or function as in Excel). The InStr function in Excel is
equivalent to the Search function in Excel, but the syntax is difference.

Try:

=IIf(ISERROR(LEFT(G2,InStr(G2, " ",G2))),G2,LEFT(G2,InStr(G2, " ")-1))
 

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