|
下面是坛里找到的权限设置的代码,我的问题是,某一"主菜单"下的子菜单全部不可见时,息样使"主菜单"也不可见?
Function ControlRange()
'此程序由张勇武编制,可自由传播,也可对此程序提出好的建议与改进,但本人不承担任何相关责任。
'E-mail:eric_zyw@126.com
Dim aa, bb, cc As Integer
Dim rs1 As New ADODB.Recordset
Dim cn As ADODB.Connection
CommandBars("油库").Visible = True
Set cn = CurrentProject.Connection
rs1.Open "SELECT * FROM 权限 WHERE (((权限.所属用户)='" & [Forms]![登录窗口]![权限] & "'));", cn, adOpenKeyset, adLockOptimistic
cn.BeginTrans
'cn.BeginTrans
rs1.MoveFirst
Do Until rs1.EOF
aa = rs1.Fields("主菜单")
bb = rs1.Fields("子菜单")
cc = rs1.Fields("有效")
Set mybars = CommandBars("油库").Controls(aa).CommandBar.Controls(bb)
If cc = 0 Then
mybars.Visible = False
Else
mybars.Visible = True
End If
rs1.MoveNext
Loop
cn.CommitTrans
Set rs1 = Nothing
End Function |
|