tempvars show as null when used in a function!

tempvars variable does not show value when used in function!  

I set the variable in a login form to use throughout the project and that works fine!
TempVars.Add "log_usr", UserName

But when I try to use it in a function it shows NULL.

On a form I put this on a button! I'll use it on an autokeys macro later once it works!  
    DoCmd.OpenFunction Open_user_text()

    Function Open_user_text()


        MsgBox (" User =") & tempvars!UserName

    End Function


Peter GrovesAsked:
Who is Participating?
Dale FyeCommented:
You need to use the name of the tempvar you created:

        MsgBox (" User =") & tempvars!log_Usr
Peter GrovesAuthor Commented:
I knew I had to be doing something real dumb. I was using the variable that loads the Tempvars at the logon form
rather than the Tempvars variable that was created!  



Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.