Replace

J

JoHickey

I need to replace everything past a specific character "~" with nothing. For
example:

West Elgin~West Elgin~West Elgin
Hamilton~Hamilton
Guelph~Guelph~Guelph~Guelph

I would like to have the query return only the information up to but not
including the first ~. The problem is that the number of characters is not
the same on all records, therefore using Left or Replace isn't working.

Any help would be appreciated. Thanks.
 
K

Klatuu

Create a calculated field in your query based on the field with the data. In
the example, x is the name of the field:

ShortStyle: left(x,instr(x,"~")-1)
 
F

fredg

I need to replace everything past a specific character "~" with nothing. For
example:

West Elgin~West Elgin~West Elgin
Hamilton~Hamilton
Guelph~Guelph~Guelph~Guelph

I would like to have the query return only the information up to but not
including the first ~. The problem is that the number of characters is not
the same on all records, therefore using Left or Replace isn't working.

Any help would be appreciated. Thanks.

Left() works fine.
You just need to find the position of the first "~" using InStr(), and
subtract 1.

NewColumn:Left([FieldName],InStr([FieldName],"~")-1)
 

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