Access 2007/2010 VBA基于Windows认证的用户管理

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Private Sub Form_Load()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Select UserRole,FirstName,LastName From tblUser Where UserDomain='" & Environ("USERDOMAIN") & "\" & Environ("USERNAME") & "'", 2)
If Not rs.EOF Then
    'rs.MoveNext
    If Val(rs("UserRole")) = 4 Then
        UserMaintainmancePage.Visible = False
    End If
    lbl.Caption = Replace(lbl.Caption, "!", rs("FirstName") & " " & rs("LastName") & "!")
    Data_Source_Table.Visible = False
    Tech_Alerts_Table.Visible = False
    tblUser_View.SourceObject = "Query.tblUser View"
Else
    MsgBox "You cannot access the system, please find your Boss."
    Application.Quit
End If
Set rs = Nothing
End Sub

Private Sub UserFind()
tblUser_View.Visible = True
FindUserTxt.SetFocus
FindUserTxt.Tag = FindUserTxt.Text
FindFirstNameTxt.SetFocus
FindFirstNameTxt.Tag = FindFirstNameTxt.Text
FindLastNameTxt.SetFocus
FindLastNameTxt.Tag = FindLastNameTxt.Text
tblUser_View.Requery
End Sub