Trim after space

J

Jay

In a query I want to remove anything after a space in a
field. Example is First_Name has a middle inital in it.
In my query I want to remove this. Does every know a name
of a function that will do this?

Now:
First_Name
Jon M

Looking for:
First_Name
Jon

Thanks for the help.
 
B

Bruce M. Thompson

In a query I want to remove anything after a space in a
field. Example is First_Name has a middle inital in it.
In my query I want to remove this. Does every know a name
of a function that will do this?

Now:
First_Name
Jon M

Looking for:
First_Name
Jon

Update to:

Mid([First_Name],1,instr([First_Name]," ")-1)
 
J

Jay

I received a #Error on some of the records.
-----Original Message-----
In a query I want to remove anything after a space in a
field. Example is First_Name has a middle inital in it.
In my query I want to remove this. Does every know a name
of a function that will do this?

Now:
First_Name
Jon M

Looking for:
First_Name
Jon

Update to:

Mid([First_Name],1,instr([First_Name]," ")-1)

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 
S

Shane G. Brodie

I assume you have one or more records where there is no middle name and
hence no space ... try a small variation on Bruce's example:

IIf(InStr([Table1]![F_Name]," "),Mid([F_Name],1,InStr([F_Name],"
")-1),[Table1]![F_Name])


Regards


--
Shane Brodie
IT Consultant
c/o MANITOBA FILM & SOUND
410-93 Lombard Avenue
Winnipeg MB R3B 1B3
tel 204-947-2040
website: http://www.mbfilmsound.mb.ca
e-mail: (e-mail address removed)

Jay said:
I received a #Error on some of the records.
-----Original Message-----
In a query I want to remove anything after a space in a
field. Example is First_Name has a middle inital in it.
In my query I want to remove this. Does every know a name
of a function that will do this?

Now:
First_Name
Jon M

Looking for:
First_Name
Jon

Update to:

Mid([First_Name],1,instr([First_Name]," ")-1)

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)
No Email, Please. Keep all communications
within the newsgroups so that all might benefit.<<


.
 
B

Bruce M. Thompson

I received a #Error on some of the records.

Oops! My bad. Try this instead (watch for line wrap - it's all on one line):

IIf(Not IsNull([First_Name]), IIf(instr([First_Name],"
"),Mid([First_Name],1,instr([First_Name]," ")-1), [First_Name]),
[First_Name])

Sorry about that. :)
 
J

Jay

Worked Thanks!!
-----Original Message-----
I assume you have one or more records where there is no middle name and
hence no space ... try a small variation on Bruce's example:

IIf(InStr([Table1]![F_Name]," "),Mid([F_Name],1,InStr ([F_Name],"
")-1),[Table1]![F_Name])


Regards


--
Shane Brodie
IT Consultant
c/o MANITOBA FILM & SOUND
410-93 Lombard Avenue
Winnipeg MB R3B 1B3
tel 204-947-2040
website: http://www.mbfilmsound.mb.ca
e-mail: (e-mail address removed)

Jay said:
I received a #Error on some of the records.
-----Original Message-----
In a query I want to remove anything after a space in a
field. Example is First_Name has a middle inital in it.
In my query I want to remove this. Does every know
a
name
of a function that will do this?

Now:
First_Name
Jon M

Looking for:
First_Name
Jon

Update to:

Mid([First_Name],1,instr([First_Name]," ")-1)

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)
No Email, Please. Keep all communications
within the newsgroups so that all might benefit.<<


.


.
 

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