在我的MS-Access数据库中,我获得了一个LoginForm,该表单检查用户是否可以访问特定表单。
我的主叫“ NavigationsFormular”有4个标签
普通用户可以访问名为“ Bautagesbericht”的第一个标签。
控制用户可以访问第二,第三,第四选项卡,但不能访问第一!
“登录表单”在开始时是一个弹出窗口,我也不想将其更改为选项卡,这很丑陋,也不是最佳选择。
登录成功后,它将加载Navigationform。
对于普通用户来说,这没问题,但是对于控制部分,它总是显示“ No access”,因为它试图打开一个不允许的标签。
多数民众赞成在代码:
If Globals.UserAccess(Me.Name) = False Then
MsgBox " No access!"
DoCmd.Close acForm, Me.Name
End If
现在我的想法是,登录表单打开该表单,用户可以通过以下代码获得权限:
If Globals.UserAccess("frm_Räumstellenerfassung") = False Then
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frm_Taetigkeitseingabe_Büro", _
PathToSubformControl:="Navigationsformular.NavigationsUnterformular>frm_Taetigkeitseingabe_Büro.NavigationsUnterformular"
DoCmd.Close acForm, Me.Name
Else
DoCmd.OpenForm "Navigationsformular"
DoCmd.Close acForm, Me.Name
End If
End Sub
Hauptformular1 / MainFormular1 =“ NavigationsFormular”
Unterformular1 / SubForm1 =“ NavigationsUnterformular”(德语)
Formular1 =“frm_Taetigkeitseingabe_Büro”
尝试所有组合都无济于事。
顺便说一句:在我的Naviagtion表单中带有此代码的按钮正在工作。显然不是从其他形式尝试时。
DoCmd.BrowseTo acBrowseToForm, "frm_Taetigkeitseingabe_Büro","Navigationsformular.NavigationsUnterformular"
答案 0 :(得分:0)
好吧,我跟随@ June7小费。感谢那。这是我的解决方法:
将我的表格“frm_Räumstellenerfassung”(Bautagesbericht)编辑为
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
If Globals.UserAccess("frm_Räumstellenerfassung") = False Then
DoCmd.BrowseTo acBrowseToForm, "frm_Taetigkeitseingabe_Büro", "Navigationsformular.NavigationsUnterformular"
End If
End Sub
因此,不再弹出消息“ No Access”,并且如果用户无权查看此表单,则浏览到第二个选项卡(Tätigkeitserfassung),而不会看到第一表单的任何详细信息。
“我的登录”按钮只需导航至导航表单
DoCmd.OpenForm "Navigationsformular"
DoCmd.Close acForm, Me.Name