Trimming Fields

N

Nick hfrupn

I have a form where I enter a person’s first names. What I would like to do
is trim off anything after the first of multiple names e.g. Fred Jonathon,
loose the space and Jonathon so that only Fred is left.

Is this possible?

Regards
Nick
 
S

Stefan Hoffmann

hi Nick,

Nick said:
I have a form where I enter a person’s first names. What I would like to do
is trim off anything after the first of multiple names e.g. Fred Jonathon,
loose the space and Jonathon so that only Fred is left.
Try this piece of code in the BeforeUpdate event:

Dim Pos As Integer
Dim Str As String

Str = LTrim(ctlTextbox.Text)
Pos = InStr(Str, " ")
If Pos > 0 Then
ctlTextbox.Text = Left(Str, Pos - 1)
End If



mfG
--> stefan <--
 
Top