新建一个窗体“测试单独打开子窗体权限”,对子窗体添加/删除权限做测试。给“无权限”按钮赋予如下代码:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
DoCmd.OpenForm "子窗体", acFormDS, , , , acWindowNormal Forms![子窗体].AllowDeletions = False
Forms![子窗体].AllowAdditions = False
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
此时打开的“子窗体”无删除/添加权限。
再新建一个窗体“打开主窗体时权限”,欲单击“无权限”按钮时,打开“主窗体”,同时主窗体中的“子窗体”无添加/删除权限,给“无权限”按钮赋予如下代码,但是经测试不行啊,求高手帮忙,小弟先谢过!
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.OpenForm "主窗体", , , stLinkCriteria Forms![主窗体]![子窗体].AllowDeletions = False
Forms![主窗体]![子窗体].AllowAdditions = False
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
本帖{zh1}由 luyuqi 于 2010-5-10 14:56 编辑
1,采用窗体间参数传递方法,判断是否锁定窗体数据
2,在主窗体open时间加入locked命令
例:Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
End Sub
主窗体中:
Private Sub Form_Load()
Dim a As String
a = Me.OpenArgs
If a = "c" Then
Me![子窗体].Locked = True
Else
Me![子窗体].Locked = False
End If
End Sub
注:在Command0中将c 随便改一个字符串
怕你搞不懂,专门加了个注(注:在Command0中将c 随便改一个字符串),没看?
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stDocName As String
Dim stLinkCriteria As String