troubleshooting Question

Create custom Replace function

Avatar of bfuchs
bfuchsFlag for United States of America asked on
Microsoft AccessVBA
6 Comments1 Solution103 ViewsLast Modified:
Hi Experts,

I am looking to create a function that will accept a string and only return the alpha/numeric values, except for dashes all special characters should get stripped out.

So instead of having to use the following
fieldName = Left(Replace(Replace(Replace(Mid(ColumnName, 2, Len(ColumnName) - 2), " ", ""), "&", ""), "+", ""), 32)
I can call my function something like
MyReplace(sTrVar,"_")

P.S. If possible, would prefer to have the 2nd variable of the function (the one holding the dash) capable of managing more than one character as an exception, so I can send "_,-,' ') and all 3 of them would be considered valid characters, not getting stripped out.

Thanks
ASKER CERTIFIED SOLUTION
Zakaria Acharki
Analyst Developer
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros