URGENT-delete few characters in a field

C

Crystal

Hi Everyone,

In my table I have a field named Short_Description and in this field
contains various part numbers...example...6312-2RS(D), 1630-DCG(C),
SSR-10-DD(NX)...

I need to remove the characters in the paranthesis including the
paranthesis. I know there has to be an easier way to do this other than a
"Find and Replace" in the actual table...

Your help is greatly appreciated
 
V

Vincent Johns

How easy depends on the structure of your data. Can anything ever
follow the closing parenthesis? If not, just use InStr() to locate the
first one. You then know how many charaters of good stuff you have, and
you can extract them via the Left$() function.

If you need to change, e.g., "6312-2RS(D)-82(C)" to "6312-2RS-82",
you're probably stuck with writing your own function in a Module, using
VBA. (At least, I don't know of any standard Access function to do
this.) It won't take a heck of a lot of code to do this (I'm guessing
maybe 15-20 lines) but could be tricky if you've never written VBA code
before.

Having defined the function you want to use, I would recommend a
multi-step procedure:
- Back up your database. :)
- Copy the [Short_Description] field in Table Design View, giving the
copy a short, convenient name such as [SD2]
- Use an Update Query to stuff the value from [Short_Description], as
modified by your function, into [SD2].
- Delete [Short_Description], if you have no further use for it.
- Rename [SD2] to [Short_Description].

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
J

Jerry Whittle

The following will extract everything before the ( . Change Crystal to the
actual table name. Before using it as part of an update query, make sure to
back up the table if not the entire database.

SELECT Left([Short_Description],InStr([Short_Description],"(")-1) AS ShortDesc
FROM Crystal
WHERE (((InStr([Short_Description],"("))>0));
 
C

Crystal

Vincent,
You'll have to excuse me but I'm still pretty new at this...There isn't
anything that follows the closing ( ). Could you show me how to use the
InStr() and the Left$()?

Thanks

Vincent Johns said:
How easy depends on the structure of your data. Can anything ever
follow the closing parenthesis? If not, just use InStr() to locate the
first one. You then know how many charaters of good stuff you have, and
you can extract them via the Left$() function.

If you need to change, e.g., "6312-2RS(D)-82(C)" to "6312-2RS-82",
you're probably stuck with writing your own function in a Module, using
VBA. (At least, I don't know of any standard Access function to do
this.) It won't take a heck of a lot of code to do this (I'm guessing
maybe 15-20 lines) but could be tricky if you've never written VBA code
before.

Having defined the function you want to use, I would recommend a
multi-step procedure:
- Back up your database. :)
- Copy the [Short_Description] field in Table Design View, giving the
copy a short, convenient name such as [SD2]
- Use an Update Query to stuff the value from [Short_Description], as
modified by your function, into [SD2].
- Delete [Short_Description], if you have no further use for it.
- Rename [SD2] to [Short_Description].

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.

Hi Everyone,

In my table I have a field named Short_Description and in this field
contains various part numbers...example...6312-2RS(D), 1630-DCG(C),
SSR-10-DD(NX)...

I need to remove the characters in the paranthesis including the
paranthesis. I know there has to be an easier way to do this other than a
"Find and Replace" in the actual table...

Your help is greatly appreciated
 
V

Vincent Johns

Jerry Whittle's solution (in another message) ought to work pretty well
for you, since we don't have to worry about multiple parentheses.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
Vincent,
You'll have to excuse me but I'm still pretty new at this...There isn't
anything that follows the closing ( ). Could you show me how to use the
InStr() and the Left$()?

Thanks

:

How easy depends on the structure of your data. Can anything ever
follow the closing parenthesis? If not, just use InStr() to locate the
first one. You then know how many charaters of good stuff you have, and
you can extract them via the Left$() function.

If you need to change, e.g., "6312-2RS(D)-82(C)" to "6312-2RS-82",
you're probably stuck with writing your own function in a Module, using
VBA. (At least, I don't know of any standard Access function to do
this.) It won't take a heck of a lot of code to do this (I'm guessing
maybe 15-20 lines) but could be tricky if you've never written VBA code
before.

Having defined the function you want to use, I would recommend a
multi-step procedure:
- Back up your database. :)
- Copy the [Short_Description] field in Table Design View, giving the
copy a short, convenient name such as [SD2]
- Use an Update Query to stuff the value from [Short_Description], as
modified by your function, into [SD2].
- Delete [Short_Description], if you have no further use for it.
- Rename [SD2] to [Short_Description].

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.


Crystal wrote:

Hi Everyone,

In my table I have a field named Short_Description and in this field
contains various part numbers...example...6312-2RS(D), 1630-DCG(C),
SSR-10-DD(NX)...

I need to remove the characters in the paranthesis including the
paranthesis. I know there has to be an easier way to do this other than a
"Find and Replace" in the actual table...

Your help is greatly appreciated
 
Top