1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AccessのVBAでビープ音(確認音)を鳴らす

Posted at

背景

タブレットなどの『指で操作する端末』でAccessを使っている。
そういった環境の場合、ユーザーから「処理が正常終了したら音鳴らしてほしい」と要望があがることがある。

やり方(てろーんっていう固定音)

Windowsで音量を調整した時に鳴る「てろーん」でよいなら下記。

DoCmd.Beep

やり方(音の高さと長さを指定)

正常終了なら『ぽ↓ぴ↑』
エラーなら『ぶ→ぶ→ぶ→』
のように鳴る音を変えたい場合。

この方法はかなりデカいビープ音出るので注意。

'『kernel32.dll』の力を借りるとカスタム音を鳴らせる。
Private Declare Function Beep Lib "kernel32.dll" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

'フォーム上にbtn_1という名前のボタンがあり、それを押した時の動作。
Private Sub btn_1_Click()
    
    '第一引数が周波数 = 音の高さ。
    '第一引数が音の長さ。
    Call Beep(1000, 70)
    Call Beep(3000, 180)

End Sub

参考サイトさん

バージョン

Windows 10 Pro 22H2 19045.3086
Microsoft Access for Microsoft 365 MSO (バージョン 2305 ビルド 16.0.16501.20074) 32 ビット

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?