 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 14th, 2004, 11:02 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Global Varibles?
Ok what I believe I am asking for is a Global variable? Well it sounds good any way what I am trying to achieve is the tracking of a user login in to the database. I have a form which allows the user to login which I wish to be able to draw on this at many occasions.
Am I able to do this?
Or am I barking up the wrong tree completely?
Simon
|
|

December 14th, 2004, 05:08 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Sort of the wrong tree.
By using Application.Currentuser you can get the login name at the computer, but by using an API call you can get the network login name. In both instances record the name in a text box on the login form (hidden if necessary) and simply refer to this textbox when you need the information.
Somewhere in my code I have the API call, if you want it I can find it
Cheers
Alan Thomas
|
|

December 15th, 2004, 08:56 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Hi,
Sorry to butt in, but I would like to see that API call to get the network ID. I have similar issues but have given up until we move from (gulp) NetWare (which totally prevents the use of Access security) to Microsoft.
Hey, why do you think my username is in 8.3 format? DOS lives, somewhere... apparently at my job site.
Thanks,
mmcdonal
|
|

December 18th, 2004, 11:31 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
|
|
API call as follows
'---------------------------------------------------------------
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
'---------------------------------------------------------------
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
strUserName = String$(255, 0)
lngLength = 255
lngResult = wu_GetUserName(strUserName, lngLength)
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
'-----------------------------------------------------------
This works in MOST OS/Network combinations, but it does sometimes have problems with NT4. Good Luck
|
|

December 18th, 2004, 11:36 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Whilst i'm at it, here is the code to get the computer name of the current user
Declare Function wu_GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
â=============================================== ==========
Function ap_GetComputerName() As Variant
Dim strComputerName As String
Dim lngLength As Long
Dim lngResult As Long
strComputerName = String$(255, 0)
lngLength = 255
lngResult = wu_GetComputerName(strComputerName, lngLength)
ap_GetComputerName = Left(strComputerName, InStr(1, strComputerName, Chr(0)) - 1)
End Function
Alan Thomas
|
|
 |