Access权限 判断函数

  1. Option Compare Database
  2. Public Const ErrQX = "权限不足!请与管理员联系!"
  3. Public YGNumber As String    '员工编号
  4. Public ygName As String    '员工姓名
  5. '///////////////////////////////////////---------验证用户权限 ------//////////////////////////////////////////////////
  6. Public Function Frm_Qx(Frm As Form, UserID As String)
  7.     '在系统表里寻找登陆用户关于打开窗体的权限记录集
  8. Dim sql As String
  9. sql = "SELECT * from Tbl_权限 where 用户='" & UserID & "'and 对象='" & Frm.Name & "';"
  10.     '打开记录集
  11. Dim db As ADODB.Connection
  12. Dim rs As New ADODB.Recordset
  13. Set db = CurrentProject.Connection    rs.Open sql, db, adOpenStatic, adLockReadOnly
  14.         '如果记录为空,改用户没有任何权限
  15. If rs.BOF And rs.EOF Then
  16. MsgBox ErrQX, vbCritical, "错误"
  17. DoCmd.RunCommand acCmdClose
  18. Exit Function
  19. End If
  20.         '如果权限为 "全部"
  21. If rs!完全 = True Then
  22. Frm.AllowAdditions = True
  23. Frm.AllowEdits = True
  24. Frm.AllowDeletions = True
  25.             Exit Function
  26. End If
  27.         '如果权限为"只读"
  28. If rs!只读 = True Then
  29. Frm.AllowAdditions = False
  30. Frm.AllowEdits = False
  31. Frm.AllowDeletions = False
  32.              Exit Function
  33. End If
  34.         '如果全是否,忘记填写了...
  35. If rs!只读 = False And rs!添加 = False And rs!删除 = False And rs!修改 = False And rs!完全 = False Then
  36. MsgBox ErrQX, vbCritical, "错误"
  37. DoCmd.RunCommand acCmdClose
  38. Exit Function
  39. End If
  40.         '其他情况就是按照正常的选择了..
  41. Frm.AllowAdditions = rs!添加
  42. Frm.AllowEdits = rs!修改
  43. Frm.AllowDeletions = rs!删除
  44. End Function

 

 

摘自  http://www.access-cn.com/info/1768-cn.html

 

版权声明:
作者:水东柳
链接:https://shuidl.com/1555.html
来源:水东柳博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>