Trimming Fields

G

Guest

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 <--
 

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