Hi Everyone!
I am struggling with how to make a variable available throughout my Ms Access Test.mdb
I am not that up on how to do this and have tried unsuccessfully to achieve this.
I know how to pass a variable form one sub to another but that is about it for my level of expertise , can anyone suggest how this is done
Reason is Every form I have needs to get the logged on users name, So I have found that I am calling the same function over and over with every form .How do you make it Public or Global or ???, the function I use is
And at the moment I dim a variable (LoggedonUser)as string in every form
I have read googled and I just can't get my head around it for my tiny little brain, So if you can help with this please I be really happy
many Thanks
I am struggling with how to make a variable available throughout my Ms Access Test.mdb
I am not that up on how to do this and have tried unsuccessfully to achieve this.
I know how to pass a variable form one sub to another but that is about it for my level of expertise , can anyone suggest how this is done
Reason is Every form I have needs to get the logged on users name, So I have found that I am calling the same function over and over with every form .How do you make it Public or Global or ???, the function I use is
Code:
Public Function GetCurrentUserName() As String
On Error GoTo Err_GetCurrentUserName
Dim lpBuff As String * 25
Dim ret As Long, Username As String
ret = GetUserName(lpBuff, 25)
Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
GetCurrentUserName = Username & ""
Exit_GetCurrentUserName:
Exit Function
Err_GetCurrentUserName:
MsgBox Err.Description
Resume Exit_GetCurrentUserName
End Function
I have read googled and I just can't get my head around it for my tiny little brain, So if you can help with this please I be really happy
many Thanks