My Assistant
![]() ![]() |
|
|
Aug 19 2010, 01:23 PM
Post
#1
|
|
|
UtterAccess Member Posts: 26 |
I have an accde and was curious if it is possible to have the Submit onclick procedure capture the logged on user of the PC who is running the form and/or the pc name, and insert them into a table field.
ANyone know how I can accomplish this? to dive in deeper.. How can I validate the logged on user to allow or deny the submission? Thanks for any direction on this. |
|
|
|
Aug 19 2010, 01:39 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 8,106 From: CT |
do you have a table with authorized usernames ??
|
|
|
|
Aug 19 2010, 01:44 PM
Post
#3
|
|
|
UtterAccess Member Posts: 26 |
no.. but that will not be difficult to accomplish.. I only have 10 users
|
|
|
|
Aug 19 2010, 01:50 PM
Post
#4
|
|
|
UtterAccess VIP Posts: 8,106 From: CT |
There are a few ways you can go depending on how much you want to do. You can create a login screen where they enter their name, you compare it to this new table and if they are in it they get your main form. Then you can also have in that table an access level number. If the number is say 5 then they are run reports only. if it is a 10 then they can open forms. If you don't want to do it that way, look at this link.
http://www.databasedev.co.UK/get_username_...mputername.html |
|
|
|
Aug 19 2010, 02:01 PM
Post
#5
|
|
|
UtterAccess Editor Posts: 15,965 From: Northern Virginia, USA |
A simple way to get the current user is with this VBA command ...
Environ("UserName") ---- But most consider the following api call's and VBA User Defined Functions to be the preferred methods ... CODE Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _ "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Declare Function apiGetComputerName Lib "kernel32" Alias _ "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Public Function GetComputerName() As String 'Returns the computername Dim lngLen As Long, lngX As Long Dim strCompName As String lngLen = 16 strCompName = String$(lngLen, 0) lngX = apiGetComputerName(strCompName, lngLen) If lngX <> 0 Then GetComputerName = Left$(strCompName, lngLen) Else GetComputerName = "" MsgBox "", vbYesNo End If End Function Public Function GetUserName() As String ' Returns the network login name Dim lngLen As Long, lngX As Long Dim strUserName As String strUserName = String$(254, 0) lngLen = 255 lngX = apiGetUserName(strUserName, lngLen) If lngX <> 0 Then GetUserName = Left$(strUserName, lngLen - 1) Else GetUserName = "" End If End Function Edits: Sorry for dup info (IMG:style_emoticons/default/dazed.gif) |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 04:36 PM |