R
Rich Adams
I am working with an access database and I need to set it up for users to only have access to certain areas. I have looked at the security setting built into Access and I know I can use them if I have to. What my question is:
1. I have VB code from an Excel application that will allow me to get the name of the peson on the computer, pulled from the windows login which all of our users have different login names and passwords (we are on a network). The code I have is listed below.
2. Is there a way to set-up Access to use this as the user name and thus nobody would have to type in a password to get in. Whenever you log into the computer and open up Access it would know who you are and thus you would have access rights based on your actuall login.
I am sorry if this is a little confusing, I am struggling to explain exactly what I am wanting. Basically I want to use the User Name in the Windows Log In screen to use as the name for access, then I can assign that name as a usergroup and give them certain rights. But how to I make access except this as the user name instead of making someone type it in.
Thank you for any advise you have have, and if you need me to try and explain this differently please let me know.
Rich Adams
' Declare for call to mpr.dll.
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long
Const NOERROR = 0 'The Function call was successful
Sub GetUserNameForLogIn()
' Buffer size for the return string.
Const lpnLength As Integer = 255
' Get return buffer space.
Dim status As Integer
' For getting user information.
Dim lpName, lpUserName As String
' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)
' Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)
' See whether error occurred.
If status = NOERROR Then
' This line removes the null character. Strings in C are null-
' terminated. Strings in Visual Basic are not null-terminated.
' The null character must be removed from the C strings to be used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
' An error occurred.
On Error Resume Next
End
End If
'Display the name of the person logged on to the machine.
MsgBox "The person logged on this machine is: " & lpUserName
End Sub
1. I have VB code from an Excel application that will allow me to get the name of the peson on the computer, pulled from the windows login which all of our users have different login names and passwords (we are on a network). The code I have is listed below.
2. Is there a way to set-up Access to use this as the user name and thus nobody would have to type in a password to get in. Whenever you log into the computer and open up Access it would know who you are and thus you would have access rights based on your actuall login.
I am sorry if this is a little confusing, I am struggling to explain exactly what I am wanting. Basically I want to use the User Name in the Windows Log In screen to use as the name for access, then I can assign that name as a usergroup and give them certain rights. But how to I make access except this as the user name instead of making someone type it in.
Thank you for any advise you have have, and if you need me to try and explain this differently please let me know.
Rich Adams
' Declare for call to mpr.dll.
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long
Const NOERROR = 0 'The Function call was successful
Sub GetUserNameForLogIn()
' Buffer size for the return string.
Const lpnLength As Integer = 255
' Get return buffer space.
Dim status As Integer
' For getting user information.
Dim lpName, lpUserName As String
' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)
' Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)
' See whether error occurred.
If status = NOERROR Then
' This line removes the null character. Strings in C are null-
' terminated. Strings in Visual Basic are not null-terminated.
' The null character must be removed from the C strings to be used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
' An error occurred.
On Error Resume Next
End
End If
'Display the name of the person logged on to the machine.
MsgBox "The person logged on this machine is: " & lpUserName
End Sub