我正在尝试从访问模块中更改表单AllowEdits属性。目前我只是在每个单独的表单中都有代码,但我正在寻找一种方法来简单地将表单传递给模块,在模块中它将更改AllowEdits属性以保持表单模块清洁和轻松。
目前我的格式是:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
FormLocker.F9Unlocker myForm: Me.Form , KeyCode: KeyCode , Shift: Shift
End Sub
在我的模块中我有
Public Sub F9Unlocker(ByRef myForm As Form, ByRef KeyCode As Integer, ByRef Shift As Integer)
If KeyCode = 120 Then
If myForm.AllowEdits = False Then
myForm.AllowEdits = True
myForm.AllowAdditions = True
myForm.AllowDeletions = True
Else
myForm.AllowAdditions = False
myForm.AllowEdits = False
myForm.AllowDeletions = False
End If
End If
End Sub
目前它不断给我类型不匹配错误,此时我甚至不确定它是否可能。有什么建议吗?