A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Remove text in brackets from query



 
 
Thread Tools Display Modes
  #11  
Old August 15th, 2005, 09:29 PM
JanetF
external usenet poster
 
Posts: n/a
Default

Hi Ken,

Thanks for your help, but when I use this I get an error message saying that
I entered a function containing the wrong number of arguments. Any idea why?

I'm just going to reiterate what my problem is, as I think I haven't been
very clear up till now. I have several name fields in my query, and the one
I'm having problems with is called PatientRegistry.[GIVEN_NAMES] The data in
this field includes first name, middle name, and any other given names, but
also sometimes has comments in brackets. For example you might see: Janet
(NMN) or Janet (Elizabeth). They are round brackets, and I would like to
remove them along with whatever is within them. In other words I would like
all records to show in my query, but those records that have bracketed text
included in the GIVEN_NAMES field, to only show the text outside the
brackets. So instead of showing Janet (NMN) it would only show Janet.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Sorry...typo:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0, Len([FirstName]),
InStr([FirstName], "[")-1))

--

Ken Snell
MS ACCESS MVP

"Ken Snell [MVP]" wrote in message
...
Giving a completely generic answer sometimes is misleading, especially
when one learns (as you have said here) that the original question was not
complete.

Something such as this:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0, Len([FirstName],
InStr([FirstName], "[")-1)

--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Thanks, but I need a bit more information than that. The text in
brackets is
sometimes there and sometimes not. It can be any imaginable length. I
need
to know how to not include anything in brackets in the query results.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after
the
first name. I would like to remove the brackets and the text within
the
brackets. How do I go about doing this? Thanks in advance.

Janet








  #12  
Old August 15th, 2005, 09:57 PM
JanetF
external usenet poster
 
Posts: n/a
Default

Ofer,

I have something really strange happening. When I used the function you
gave here, it worked after I entered it and when I first ran the query, but
then when I closed the query and saved it, then reopened it only half the
amount of records were showing that were originally there. I don't
understand what is happening. Any idea? Thanks again for your help.

Janet

"Ofer" wrote:

In the first post you asked for
would like to remove the brackets and the text within the brackets

In that case try and use the replace function to remove the brackets

Replace(Replace(FieldName,"[",""),"]","")

I hoped that helped

--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I just thanked you for this and said it worked, but after looking more
closely at my query results, I realized that what happened was all records
that included bracketed text in the "GIVEN_NAMES" field are now not showing.
I need them to show, just without the bracketed text included. Hope you can
help. Thanks.

Janet

"Ofer" wrote:

You can try this

IIF(instr(FieldName,"[")=true,left(FieldName,instr(FieldName,"[")-1) &
mid(FieldName,instr(FieldName,"]")+1), FieldName)


--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Thanks, but I need a bit more information than that. The text in brackets is
sometimes there and sometimes not. It can be any imaginable length. I need
to know how to not include anything in brackets in the query results. Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after the
first name. I would like to remove the brackets and the text within the
brackets. How do I go about doing this? Thanks in advance.

Janet



  #13  
Old August 15th, 2005, 10:07 PM
Ofer
external usenet poster
 
Posts: n/a
Default

Can you post your SQL?
--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I have something really strange happening. When I used the function you
gave here, it worked after I entered it and when I first ran the query, but
then when I closed the query and saved it, then reopened it only half the
amount of records were showing that were originally there. I don't
understand what is happening. Any idea? Thanks again for your help.

Janet

"Ofer" wrote:

In the first post you asked for
would like to remove the brackets and the text within the brackets

In that case try and use the replace function to remove the brackets

Replace(Replace(FieldName,"[",""),"]","")

I hoped that helped

--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I just thanked you for this and said it worked, but after looking more
closely at my query results, I realized that what happened was all records
that included bracketed text in the "GIVEN_NAMES" field are now not showing.
I need them to show, just without the bracketed text included. Hope you can
help. Thanks.

Janet

"Ofer" wrote:

You can try this

IIF(instr(FieldName,"[")=true,left(FieldName,instr(FieldName,"[")-1) &
mid(FieldName,instr(FieldName,"]")+1), FieldName)


--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Thanks, but I need a bit more information than that. The text in brackets is
sometimes there and sometimes not. It can be any imaginable length. I need
to know how to not include anything in brackets in the query results. Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after the
first name. I would like to remove the brackets and the text within the
brackets. How do I go about doing this? Thanks in advance.

Janet



  #14  
Old August 15th, 2005, 10:33 PM
Chaim
external usenet poster
 
Posts: n/a
Default

Those 'round brackets' are called parentheses. None of what went before will
work unless you substitute '(' for every '[' and ')' for every ']'.

I would assume that's why Ken's and Ofer's suggestions are not getting you
what you want.
--
Chaim


"JanetF" wrote:

Hi Ken,

Thanks for your help, but when I use this I get an error message saying that
I entered a function containing the wrong number of arguments. Any idea why?

I'm just going to reiterate what my problem is, as I think I haven't been
very clear up till now. I have several name fields in my query, and the one
I'm having problems with is called PatientRegistry.[GIVEN_NAMES] The data in
this field includes first name, middle name, and any other given names, but
also sometimes has comments in brackets. For example you might see: Janet
(NMN) or Janet (Elizabeth). They are round brackets, and I would like to
remove them along with whatever is within them. In other words I would like
all records to show in my query, but those records that have bracketed text
included in the GIVEN_NAMES field, to only show the text outside the
brackets. So instead of showing Janet (NMN) it would only show Janet.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Sorry...typo:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0, Len([FirstName]),
InStr([FirstName], "[")-1))

--

Ken Snell
MS ACCESS MVP

"Ken Snell [MVP]" wrote in message
...
Giving a completely generic answer sometimes is misleading, especially
when one learns (as you have said here) that the original question was not
complete.

Something such as this:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0, Len([FirstName],
InStr([FirstName], "[")-1)

--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Thanks, but I need a bit more information than that. The text in
brackets is
sometimes there and sometimes not. It can be any imaginable length. I
need
to know how to not include anything in brackets in the query results.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after
the
first name. I would like to remove the brackets and the text within
the
brackets. How do I go about doing this? Thanks in advance.

Janet








  #15  
Old August 15th, 2005, 10:48 PM
JanetF
external usenet poster
 
Posts: n/a
Default

Ofer,

I've changed the names of all the fields and tables, but here it is:

SELECT DISTINCT ClientRegistry.RECORD_STATUS, ClientRegistry.CLIENT_NUM,
ClientRegistry.CODE, ClientRegistry.LAST_NAME,
Replace(Replace([ClientRegistry].[GIVEN_NAMES],"(",""),")","") AS Expr1,
ClientRegistry.LAST_ENCOUNTER_DATE, ClientRegistry.ARRAY,
Encounter.CURR_ADDR_LINE_1, Encounter.CURR_ADDR_LINE_2,
Encounter.CURR_ADDR_CITY, Encounter.CURR_ADDR_PROVINCE,
Encounter.CURR_ADDR_POSTAL_CODE,
[Encounter].[CLIENT_HPHONE_AREA_CODE]+[Encounter].[CLIENT_HPHONE_NUMBER] AS
Phone, Encounter.DATE, EncounterHistory.DATE
FROM (ClientRegistry LEFT JOIN Encounter ON (ClientRegistry.CLIENT_NUM =
Encounter.CLIENT_NUM) AND (ClientRegistry.LAST_ENCOUNTER_DATE =
Encounter.DATE)) LEFT JOIN EncounterHistory ON (ClientRegistry.CLIENT_NUM =
EncounterHistory.CLIENT_NUM) AND (ClientRegistry.LAST_ENCOUNTER_DATE =
EncounterHistory.DATE)
WHERE (((ClientRegistry.RECORD_STATUS)="") AND
((ClientRegistry.LAST_ENCOUNTER_DATE)=#4/4/2002#) AND
((ClientRegistry.ARRAY)=0));

So it's the GIVEN_NAMES field where I only want to show the Given Names, not
any additional text in brackets. For example, in a Given Name field one
record may have: Janet (NMN). I only want to show Janet, not the (NMN).
Thanks.

Janet

"Ofer" wrote:

Can you post your SQL?
--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I have something really strange happening. When I used the function you
gave here, it worked after I entered it and when I first ran the query, but
then when I closed the query and saved it, then reopened it only half the
amount of records were showing that were originally there. I don't
understand what is happening. Any idea? Thanks again for your help.

Janet

"Ofer" wrote:

In the first post you asked for
would like to remove the brackets and the text within the brackets

In that case try and use the replace function to remove the brackets

Replace(Replace(FieldName,"[",""),"]","")

I hoped that helped

--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I just thanked you for this and said it worked, but after looking more
closely at my query results, I realized that what happened was all records
that included bracketed text in the "GIVEN_NAMES" field are now not showing.
I need them to show, just without the bracketed text included. Hope you can
help. Thanks.

Janet

"Ofer" wrote:

You can try this

IIF(instr(FieldName,"[")=true,left(FieldName,instr(FieldName,"[")-1) &
mid(FieldName,instr(FieldName,"]")+1), FieldName)


--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Thanks, but I need a bit more information than that. The text in brackets is
sometimes there and sometimes not. It can be any imaginable length. I need
to know how to not include anything in brackets in the query results. Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after the
first name. I would like to remove the brackets and the text within the
brackets. How do I go about doing this? Thanks in advance.

Janet



  #16  
Old August 15th, 2005, 10:58 PM
JanetF
external usenet poster
 
Posts: n/a
Default

Actually I did that and still nothing works.

"Chaim" wrote:

Those 'round brackets' are called parentheses. None of what went before will
work unless you substitute '(' for every '[' and ')' for every ']'.

I would assume that's why Ken's and Ofer's suggestions are not getting you
what you want.
--
Chaim


"JanetF" wrote:

Hi Ken,

Thanks for your help, but when I use this I get an error message saying that
I entered a function containing the wrong number of arguments. Any idea why?

I'm just going to reiterate what my problem is, as I think I haven't been
very clear up till now. I have several name fields in my query, and the one
I'm having problems with is called PatientRegistry.[GIVEN_NAMES] The data in
this field includes first name, middle name, and any other given names, but
also sometimes has comments in brackets. For example you might see: Janet
(NMN) or Janet (Elizabeth). They are round brackets, and I would like to
remove them along with whatever is within them. In other words I would like
all records to show in my query, but those records that have bracketed text
included in the GIVEN_NAMES field, to only show the text outside the
brackets. So instead of showing Janet (NMN) it would only show Janet.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Sorry...typo:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0, Len([FirstName]),
InStr([FirstName], "[")-1))

--

Ken Snell
MS ACCESS MVP

"Ken Snell [MVP]" wrote in message
...
Giving a completely generic answer sometimes is misleading, especially
when one learns (as you have said here) that the original question was not
complete.

Something such as this:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0, Len([FirstName],
InStr([FirstName], "[")-1)

--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Thanks, but I need a bit more information than that. The text in
brackets is
sometimes there and sometimes not. It can be any imaginable length. I
need
to know how to not include anything in brackets in the query results.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after
the
first name. I would like to remove the brackets and the text within
the
brackets. How do I go about doing this? Thanks in advance.

Janet








  #17  
Old August 15th, 2005, 11:13 PM
Ofer
external usenet poster
 
Posts: n/a
Default

If you don't want the additional text in brackets, as you originally posted,
then try and use my first suggestion.
About the amount of records that been displayed, it got to do with the
filter and not with the fact the you changed the name.
Try and add that to the filter

WHERE (ClientRegistry.RECORD_STATUS="" OR ClientRegistry.RECORD_STATUS is
Null) AND
ClientRegistry.LAST_ENCOUNTER_DATE =#4/4/2002# AND
ClientRegistry.ARRAY=0

In any case, mybe one of the filers remove alot of the records
==========================================

--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I've changed the names of all the fields and tables, but here it is:

SELECT DISTINCT ClientRegistry.RECORD_STATUS, ClientRegistry.CLIENT_NUM,
ClientRegistry.CODE, ClientRegistry.LAST_NAME,
Replace(Replace([ClientRegistry].[GIVEN_NAMES],"(",""),")","") AS Expr1,
ClientRegistry.LAST_ENCOUNTER_DATE, ClientRegistry.ARRAY,
Encounter.CURR_ADDR_LINE_1, Encounter.CURR_ADDR_LINE_2,
Encounter.CURR_ADDR_CITY, Encounter.CURR_ADDR_PROVINCE,
Encounter.CURR_ADDR_POSTAL_CODE,
[Encounter].[CLIENT_HPHONE_AREA_CODE]+[Encounter].[CLIENT_HPHONE_NUMBER] AS
Phone, Encounter.DATE, EncounterHistory.DATE
FROM (ClientRegistry LEFT JOIN Encounter ON (ClientRegistry.CLIENT_NUM =
Encounter.CLIENT_NUM) AND (ClientRegistry.LAST_ENCOUNTER_DATE =
Encounter.DATE)) LEFT JOIN EncounterHistory ON (ClientRegistry.CLIENT_NUM =
EncounterHistory.CLIENT_NUM) AND (ClientRegistry.LAST_ENCOUNTER_DATE =
EncounterHistory.DATE)
WHERE (((ClientRegistry.RECORD_STATUS)="") AND
((ClientRegistry.LAST_ENCOUNTER_DATE)=#4/4/2002#) AND
((ClientRegistry.ARRAY)=0));

So it's the GIVEN_NAMES field where I only want to show the Given Names, not
any additional text in brackets. For example, in a Given Name field one
record may have: Janet (NMN). I only want to show Janet, not the (NMN).
Thanks.

Janet

"Ofer" wrote:

Can you post your SQL?
--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I have something really strange happening. When I used the function you
gave here, it worked after I entered it and when I first ran the query, but
then when I closed the query and saved it, then reopened it only half the
amount of records were showing that were originally there. I don't
understand what is happening. Any idea? Thanks again for your help.

Janet

"Ofer" wrote:

In the first post you asked for
would like to remove the brackets and the text within the brackets

In that case try and use the replace function to remove the brackets

Replace(Replace(FieldName,"[",""),"]","")

I hoped that helped

--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Ofer,

I just thanked you for this and said it worked, but after looking more
closely at my query results, I realized that what happened was all records
that included bracketed text in the "GIVEN_NAMES" field are now not showing.
I need them to show, just without the bracketed text included. Hope you can
help. Thanks.

Janet

"Ofer" wrote:

You can try this

IIF(instr(FieldName,"[")=true,left(FieldName,instr(FieldName,"[")-1) &
mid(FieldName,instr(FieldName,"]")+1), FieldName)


--
In God We Trust - Everything Else We Test


"JanetF" wrote:

Thanks, but I need a bit more information than that. The text in brackets is
sometimes there and sometimes not. It can be any imaginable length. I need
to know how to not include anything in brackets in the query results. Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets after the
first name. I would like to remove the brackets and the text within the
brackets. How do I go about doing this? Thanks in advance.

Janet



  #18  
Old August 16th, 2005, 04:07 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

I must assume that what you pasted/copied/typed into your query is not
exactly what I posted, then. You'll need to post the SQL statement of your
query (as Ofer requested) -- open the query in design view, click on Query
View icon on toolbar, select SQL, copy the statement that you see, and post
it here exactly as it is. Do not modify it in any way.

--

Ken Snell
MS ACCESS MVP

"JanetF" wrote in message
...
Hi Ken,

Thanks for your help, but when I use this I get an error message saying
that
I entered a function containing the wrong number of arguments. Any idea
why?

I'm just going to reiterate what my problem is, as I think I haven't been
very clear up till now. I have several name fields in my query, and the
one
I'm having problems with is called PatientRegistry.[GIVEN_NAMES] The data
in
this field includes first name, middle name, and any other given names,
but
also sometimes has comments in brackets. For example you might see:
Janet
(NMN) or Janet (Elizabeth). They are round brackets, and I would like to
remove them along with whatever is within them. In other words I would
like
all records to show in my query, but those records that have bracketed
text
included in the GIVEN_NAMES field, to only show the text outside the
brackets. So instead of showing Janet (NMN) it would only show Janet.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Sorry...typo:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0,
Len([FirstName]),
InStr([FirstName], "[")-1))

--

Ken Snell
MS ACCESS MVP

"Ken Snell [MVP]" wrote in message
...
Giving a completely generic answer sometimes is misleading, especially
when one learns (as you have said here) that the original question was
not
complete.

Something such as this:

MyName: Left([FirstName], IIf(InStr([FirstName], "[")=0,
Len([FirstName],
InStr([FirstName], "[")-1)

--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Thanks, but I need a bit more information than that. The text in
brackets is
sometimes there and sometimes not. It can be any imaginable length.
I
need
to know how to not include anything in brackets in the query results.
Thanks.

Janet

"Ken Snell [MVP]" wrote:

Look at the Left, InStr, etc. string functions to do what you want.
--

Ken Snell
MS ACCESS MVP


"JanetF" wrote in message
...
Hello,

I have a first name field in a query that has text in brackets
after
the
first name. I would like to remove the brackets and the text
within
the
brackets. How do I go about doing this? Thanks in advance.

Janet










 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Subforms? AccessRookie Using Forms 7 April 8th, 2005 09:30 AM
Outline Renee Hendershott Page Layout 2 December 25th, 2004 02:49 PM
Complex Query (was: Refresh vs. requery vs. Remove Filter in FormsCoding NG) rgrantz Running & Setting Up Queries 1 November 23rd, 2004 01:59 AM
Union Query Not Returning A Value Jeff G Running & Setting Up Queries 2 October 19th, 2004 05:47 PM
Extract Text Outside of Brackets Frank Kabel Worksheet Functions 2 February 11th, 2004 07:38 AM


All times are GMT +1. The time now is 05:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.