Replace a / in a string

S

Stever

I can't seem to find a good way to replace a \ with a _ in a string.
For example, I have the string 'A/E Group' I would like the VBA to return
A_E Group.

Thanks in advance for any suggestions you may have.

Steve
 
F

fredg

I can't seem to find a good way to replace a \ with a _ in a string.
For example, I have the string 'A/E Group' I would like the VBA to return
A_E Group.

Thanks in advance for any suggestions you may have.

Steve

Which is it, the "\" or the "/" you wish to replace? :)
How this is done is Access version dependent.
If you have Access 2000 or newer, in VBA:
[YourField] = Replace([YourField],"/","_")

You can use it in a Select query
Exp:Replace([YourField],"/","_")

Directly in a Control's Control Source it would be:
=Replace([YourField],"/","_")

Note: If memory serves me well, in early versions of Access 2000 you
will have to place the Replace function in a module. Then call the
module function from the query. It will work just as well.

In Access 97 you would have to write a full User Defined function to
locate and replace the character. If you need help with that, post
back.
 
S

Stever

Thanks that did the trick.

Steve



fredg said:
I can't seem to find a good way to replace a \ with a _ in a string.
For example, I have the string 'A/E Group' I would like the VBA to return
A_E Group.

Thanks in advance for any suggestions you may have.

Steve

Which is it, the "\" or the "/" you wish to replace? :)
How this is done is Access version dependent.
If you have Access 2000 or newer, in VBA:
[YourField] = Replace([YourField],"/","_")

You can use it in a Select query
Exp:Replace([YourField],"/","_")

Directly in a Control's Control Source it would be:
=Replace([YourField],"/","_")

Note: If memory serves me well, in early versions of Access 2000 you
will have to place the Replace function in a module. Then call the
module function from the query. It will work just as well.

In Access 97 you would have to write a full User Defined function to
locate and replace the character. If you need help with that, post
back.
 

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