finding two substring and replace only one

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have strings containing values:
C1+2a(i) and
+2a(i)
both with other letters in the beginning and end of the string ex.
B1C1+2a(i)XX
I want to replace +2a(i) with +2a, but not if there the string contains
C1+2a(i)

Greatful for help
 
1. Create a query using this table.

2. Drag the field into the grid.
In the Criteria row under this field, enter:
Like "*+2a(i)*" And Not Like "*C1+2a(i)*"

3. Change it to an Update query.
(Update on Query menu.)
Access adds an Update row to the grid.

4. In the Update row under this field, enter:
Replace([Field1], "+2a(i)", "+2a")
replacing Field1 with the name of your field.

5. Run the query.
(Run on Query menu.)
 
IT works!
--
Thank you.


Allen Browne skrev:
1. Create a query using this table.

2. Drag the field into the grid.
In the Criteria row under this field, enter:
Like "*+2a(i)*" And Not Like "*C1+2a(i)*"

3. Change it to an Update query.
(Update on Query menu.)
Access adds an Update row to the grid.

4. In the Update row under this field, enter:
Replace([Field1], "+2a(i)", "+2a")
replacing Field1 with the name of your field.

5. Run the query.
(Run on Query menu.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Arts said:
I have strings containing values:
C1+2a(i) and
+2a(i)
both with other letters in the beginning and end of the string ex.
B1C1+2a(i)XX
I want to replace +2a(i) with +2a, but not if there the string contains
C1+2a(i)

Greatful for help
 
Back
Top