Some sort of "Find and replace"

G

Guest

Hello,

I need to update a text field in a table which contains strings of variable
lenght separated by % character: AAAAA%BBBBB%CCCC.
How can I create a query or a function to keep in that field just the BBBBB
string?
In Excel I used find and replace:
- find A*% and replace with NULL
- find %C* and replace with NULL and I have just BBBBB string
How can I do the same thing in Access?

THX
 
D

Douglas J Steele

Is it always going to be 3 strings separated by % and you always want the
2nd string?

You can use the Split function:

Split(MyString, "%")(1)

will give you the 2nd string (it starts counting at 0)
 
G

Guest

Sometimes the first and the last string are missing...
And I have to work with Access 97

Thanks
 
D

Douglas J Steele

Well, it's possible to write a Split function for Access 97, but if you
don't know the number of substrings in advance, you're probably better off
using the InStr and Mid like Jon suggested.
 

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

Similar Threads

record counting in the same group 3
numbering records in a query 3
Excel new URL 3
sorting in excel 2
Crystal report Generation 2
Blank lines in fields 1
VB Find and Replace 10
Vlookup in Access 5

Top