Module in Access

Hi Experts,
I have a question about the module in Access.  Currently I have a module in Access is :

Function GetCaresUser()
Dim CaresUser As String
Dim CaresShortName As String

    CaresUser = Environ("Username")
    CaresShortName = Left(CaresUser, 1) & Mid(CaresUser, (InStr(CaresUser, ".") + 1), 14)
    If IsNull(CaresShortName) Then
        GetCaresUser = Null
        GetCaresUser = CaresShortName
    End If

End Function

John.Smith = jsmith (that's this module does)

This module is when a user login to the network, my access database will check if user's name is there so the user can open the database and what ever the user is doing in the database will be capture their name.  but now I'm having the problem is if the user's name is:
Jane.o'brien = I tried either jo'brien or jobrien or j"obrien
when user login to the network and open the database, it has an error message says "syntax error (missing operator) in query expression 'LoginID = 'jo'brien''.  
what shall I change in the module in order to work for both John Smith and Jane O'Brien

many thanks
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
try changing this

CaresUser = Environ("Username")


CaresUser = Replace(Environ("Username"),chr(39),"")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John TsioumprisSoftware & Systems EngineerCommented:
One quick and dirty solution is to replace the accent

Open in new window

with something else and then replace it again....accent is problematic in Access
CaresUser = replace(Environ("Username"),"'","|")
CaresShortName = Left(CaresUser, 1) & Mid(CaresUser, (InStr(CaresUser, ".") + 1), 14)
CaresShortName = replace(CaresShortName ,"|","'")

Open in new window

urjudoAuthor Commented:
Thanks for all help!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.