Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Trim 1

Status
Not open for further replies.

wvmbark

Technical User
Feb 12, 2003
135
US
I have a memo field [Description] that contains a problem description and a corrective action. The corrective action is always preceeded with "Tech Recommends:"

I.e., "#1 HF inop. Tech Recommends: Replace #1 HF receiver."

I'm running an append query and only want to capture the problem decription. How do I trim off "Tech Recommends" and what follows?

Thanks!!
 
strDescr = Mid([Description], 17)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Hey,

If you do

Right([description],Len([description])-InStr([description],':'))

you will get all the characters after :

If you want the "Tech Recommends" as well you just do

"Tech Recommends" & Right([description],Len([description])-InStr([description],':'))


Mordja



 
Thanks, but I want to append only what preceeds "Tech Recommends".

Mike
 
Oh. In that case:
Left([Description], Instr([Description], "Tech Recommends")-1)


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
TomThumbKP - thanks!

mordja - i'm trying to understand your expression. can you explain why you used the Len function?

wvmbark
 
wvmbark,

I have just done the sames as tomthumbkp, but as I thought you wanted everything after ":" i used a right statement.
While with a left statement you want a number of characters relative to the left side of the string and with a right you want a number of characters relative to the right side of the string.

So to get the number of characters that you want with a right (which in the above case wall chars after ":"), you subtract the position of the character to start from, from the length of the string.

Mordja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top