Split Text

PeteJM

Registered User.
Local time
Today, 15:03
Joined
Oct 31, 2004
Messages
28
Hi,

One one of my forms i'm using the following code on the After Update event of one of my text boxes.

Me.SD_Knownas = Left$([SD_FirstName], InStr(1, [SD_FirstName], " ") - 1)

What i'm trying to do is pull the firstname from a string of text. For Example my name is Pete James the above ode returns Pete. Perfect..

The problem is.. when i enter a name that for example Pete i get a runtime error 5?

Is there away to make it see if there is one name in the box and use that or if more than one just return the first part.

Regards

Pete
 
I haven't tried this but how about:
Me.SD_Knownas = Left$([SD_FirstName] & " ", InStr(1, [SD_FirstName] & " ", " ") - 1)
 
That worked perfectly, Thank you very much for you help.

Regards

Pete
 

Users who are viewing this thread

Back
Top Bottom