我现时使用的禁用启用SHIFT键模块代码:
Function SetBypassPropertyFalse()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Function
Function SetBypassPropertyTrue()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, True
End Function
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
写好模块代码后,分别设置禁用按钮和启用按钮,分别在各自事件生成器中写上代码:
Private Sub 禁用shift_Click()
SetBypassPropertyFalse
MsgBox "禁用shift设置成功,在下次启动应用程序时生效。请重新启动程序。", , "设置成功"
End Sub
Private Sub 启用shift_Click()
SetBypassPropertyTrue
MsgBox "启用shift设置成功,在下次启动应用程序时生效。请重新启动程序。", , "设置成功"
End Sub
以上你可试试行不行。