'Shiftキー有効無効を切り替える関数 Function ChangeProperty(strPropName As String, propType, propValue) As Integer Dim dbs As Database, prp As Property Const conPropNotFoundError = 3270 Set dbs = CurrentDb dbs.Properties(propName) = propValue ChangeProperty = True End Function 'Shiftキーを有効にする場合 ChangeProperty "AllowBypassKey", dbBoolean, True 'Shiftキーを無効にする場合 ChangeProperty "AllowBypassKey", dbBoolean, False
VBAで自動的に閉じるメッセージボックス
WScriptを使用する。
Dim shell As Object Set shell = CreateObject("WScript.Shell") shell.Popup "5秒後、自動的に閉じます", 5, "タイトルバー", vbInformation Set shell = Nothing
VBで環境変数の値を使う
Environ関数を使う。引数に%はいらない。
Environ("USERPROFILE")
結果 C:\Documents And Settings\User
MS Accessのオートナンバーの開始値を変更
ADOX(Microsoft ADO Ext. 2.X for DDL and Security)の参照設定が必要。
Dim startNo As Long startNo = InputBox("開始Noを指定してください。") Dim cat As New ADOX.Catalog Set cat.ActiveConnection = CurrentProject.Connection With cat.Tables("テーブル名").Columns .Item("フィールド名").Properties("Seed") = startNo .Refresh End With Set cat = Nothing