PDA

View Full Version : Solved: Query - Trim Based on character



ThaNguyen
10-22-2009, 12:38 PM
Hi,

Is there a way you can do a query and trim data based on on a character?

example below
T33346*1
T33347*22
T33348*2

I want to query that would trim all data after the *

any help would be greatly appreciated

Thanks

CreganTur
10-22-2009, 12:51 PM
If all of the examples you posted, there are 7 characters that preceed the data you indicated you want to trim. If this is universally true, then you could easily do this by using an Update query and use the Left() function in the Update To field of the query design view, which would look like this:

Left([FieldName],7)
replace FieldName with the name of the field that has the values you want to update.

HTH:thumb

ThaNguyen
10-22-2009, 01:10 PM
Unfortunately no there are some that have more than 7 characters

T33346*1
T33347*22
T33348*2
CB23444*12

geekgirlau
10-22-2009, 06:34 PM
Left([FieldName],Instr(1,[FieldName],"*")-1)

ThaNguyen
10-22-2009, 07:30 PM
Left([FieldName],Instr(1,[FieldName],"*")-1)


Working perfectly, thank you very much

geekgirlau
10-22-2009, 10:00 PM
Don't forget to mark this thread as Solved - option under Thread Tools at the top of the page.

ThaNguyen
10-23-2009, 07:32 AM
Don't forget to mark this thread as Solved - option under Thread Tools at the top of the page.

Done,

Thanks again:hi: