Last active
February 16, 2018 00:55
-
-
Save iizukak47/73342ed62bc568048f7e11b4cb9d63a9 to your computer and use it in GitHub Desktop.
【VBA】Access起動時のShiftキーを制御する(有効化/無効化)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'*************************************************************************************************** | |
'関数名:EnableShiftKey | |
'機 能:起動時のShiftKeyの有効化します。 | |
'*************************************************************************************************** | |
Public Function EnableShiftKey() | |
SwitchShiftKey True | |
End Function | |
'*************************************************************************************************** | |
'関数名:DisableShiftKey | |
'機 能:起動時のShiftKeyの無効化します。 | |
'*************************************************************************************************** | |
Public Function DisableShiftKey() | |
SwitchShiftKey False | |
End Function | |
'*************************************************************************************************** | |
'関数名:SwitchShiftKey | |
'引 数:True(有効)、False(無効) | |
'機 能:起動時のShiftKeyの有効・無効を制御します。 | |
'*************************************************************************************************** | |
Public Function SwitchShiftKey(ByVal varPropValue As Boolean) As Boolean | |
On Error GoTo Error | |
Dim strPropName As String | |
Dim varPropType | |
Dim db As DAO.Database | |
Dim prp As DAO.Property | |
Const conPropNotFoundError = 3270 | |
strPropName = "AllowBypassKey" | |
varPropType = dbBoolean | |
Set db = CurrentDb | |
db.Properties(strPropName) = varPropValue | |
SwitchShiftKey = True | |
Exit Function | |
Error: | |
If Err.Number = conPropNotFoundError Then | |
'プロパティが見つからない場合は追加する(初回時のみ) | |
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue) | |
db.Properties.Append prp | |
Resume Next | |
Else | |
SwitchShiftKey = False ' 認識できないエラー。 | |
Exit Function | |
End If | |
End Function | |
'*************************************************************************************************** | |
'関数名:ShiftKey | |
'引 数:True(有効)、False(無効) | |
'機 能:起動時のShiftKeyの有効・無効を表示します。 | |
'*************************************************************************************************** | |
Public Function ShiftKey() As Boolean | |
On Error GoTo Error | |
Dim strPropName As String | |
Dim varPropType | |
Dim db As DAO.Database | |
Dim prp As DAO.Property | |
Const conPropNotFoundError = 3270 | |
strPropName = "AllowBypassKey" | |
varPropType = dbBoolean | |
Set db = CurrentDb | |
If db.Properties(strPropName).Value Then | |
ShiftKey = True | |
Else | |
ShiftKey = False | |
End If | |
Exit Function | |
Error: | |
ShiftKey = True | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment