DavidDrotts
IS-IT--Management
I am building a database to track a process that requires three levels of participation, the imputer, work center manager, and one office manager (i.e. imputer inputs data…manager approves input and sends to office manager for final approval) The office manager is responsible for 6 work centers. The first two levels (imputer and work center manager) are only allowed to view information regarding their respective work centers. To accomplish this I have built three forms, one for each level, that pull its information from a query that gathers the data only relevant to that particular work center. This is my vision…upon db startup user sees a splash screen that retrieves their computer logon identify and uses that information to open only the form that that particular person has access to. (This will negate having to manage/use a password security methodology.) To achieve this I have created a table that holds each user and their respective user ID (UserID) and I am using the following (see below) code to retrieve the logon information of the user. Question…how do I connect the dots? I can make the splash screen show the user id (text1), but how do I turn that into opening the form that is for that particular user?
Thanks in advance fro your wisdom AND time!
David
Option Explicit
'windows-defined type
Private Type SYSTEM_INFO
dwOemID As Long
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Type ComputerUserInfo
UserName As String
ComputerName As String
End Type
Private Sub Command0_Click()
Dim CUI As ComputerUserInfo
GetUserInfo CUI
'show the results
DisplayResults CUI
End Sub
Private Sub GetUserInfo(CUI As ComputerUserInfo)
Dim r&, ret$
'get the user's name
ret$ = Space$(256)
r& = GetUserName(ret$, Len(ret$))
CUI.UserName = StripNull$(ret$)
'get the computers's name
ret$ = Space$(256)
r& = GetComputerName(ret$, Len(ret$))
CUI.ComputerName = StripNull$(ret$)
End Sub
Private Sub DisplayResults(CUI As ComputerUserInfo)
'fill in the labels
' Label1 = "User Name :"
' Label1 = "Computer Name :"
'show the info
'Computer User Info and Windows Registry Info
text1 = CUI.UserName
Text2 = CUI.ComputerName
End Sub
Private Function StripNull$(item$)
On Local Error Resume Next
StripNull$ = Left$(item$, InStr(item$, Chr$(0)) - 1)
End Function
Private Sub Form_Load()
Dim CUI As ComputerUserInfo
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdRefresh
GetUserInfo CUI
'show the results
DisplayResults CUI
End Sub
Private Sub Form_Timer()
On Error GoTo Err_Timer_Click
Text10 = Now()
Text16 = "Active"
DoCmd.RunCommand acCmdRefresh
Err_Timer_Click:
Text10 = Now()
Text16 = "Active"
DoCmd.RunCommand acCmdRefresh
Exit Sub
End Sub
Thanks in advance fro your wisdom AND time!
David
Option Explicit
'windows-defined type
Private Type SYSTEM_INFO
dwOemID As Long
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Type ComputerUserInfo
UserName As String
ComputerName As String
End Type
Private Sub Command0_Click()
Dim CUI As ComputerUserInfo
GetUserInfo CUI
'show the results
DisplayResults CUI
End Sub
Private Sub GetUserInfo(CUI As ComputerUserInfo)
Dim r&, ret$
'get the user's name
ret$ = Space$(256)
r& = GetUserName(ret$, Len(ret$))
CUI.UserName = StripNull$(ret$)
'get the computers's name
ret$ = Space$(256)
r& = GetComputerName(ret$, Len(ret$))
CUI.ComputerName = StripNull$(ret$)
End Sub
Private Sub DisplayResults(CUI As ComputerUserInfo)
'fill in the labels
' Label1 = "User Name :"
' Label1 = "Computer Name :"
'show the info
'Computer User Info and Windows Registry Info
text1 = CUI.UserName
Text2 = CUI.ComputerName
End Sub
Private Function StripNull$(item$)
On Local Error Resume Next
StripNull$ = Left$(item$, InStr(item$, Chr$(0)) - 1)
End Function
Private Sub Form_Load()
Dim CUI As ComputerUserInfo
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdRefresh
GetUserInfo CUI
'show the results
DisplayResults CUI
End Sub
Private Sub Form_Timer()
On Error GoTo Err_Timer_Click
Text10 = Now()
Text16 = "Active"
DoCmd.RunCommand acCmdRefresh
Err_Timer_Click:
Text10 = Now()
Text16 = "Active"
DoCmd.RunCommand acCmdRefresh
Exit Sub
End Sub