|
以下代码就是禁用和启用Shift键的函数
'禁用或启用SHIFT键
Function SetBypassProperty(Allow As Boolean)
Const DB_Boolean As Long = 1
If Allow = True Then
ChangeProperty "AllowBypassKey", DB_Boolean, True
MsgBox "启用Shift键设置成功!", vbInformation
Else
ChangeProperty "AllowBypassKey", DB_Boolean, False
MsgBox "禁用Shift键设置成功!", vbInformation
End If
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
'Dim i As Long
'For i = 1 To dbs.Properties.Count - 1
'Debug.Print dbs.Properties(i).Name
'Next i
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 |
|