0
0

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でフォームを開いてる間に一定間隔で繰り返し処理(タイマー)

Last updated at Posted at 2022-11-05

やり方

フォームのイベントの『タイマー時』で設定できる。
『タイマー間隔』の単位はミリ秒。
下記の場合、フォームを開いている間、1秒間隔で処理が行われる。
image.png

タイマー時のサンプル
Private Sub Form_Timer()
    Debug.Print Now()
End Sub

繰り返しの初回実行タイミングに注意

『タイマー間隔』が300000(5分間間隔)の場合、 フォームを開いてから5分後に Form_Timer()の 初回 が実行される。

フォームを開いたタイミングで初回が実行される訳ではないので注意。

タイマー間隔が0以下の場合

タイマー間隔は0以下に設定することもできる。
その場合、Form_Timer()は全く実行されない。
(≒ 繰り返し処理を止めている状態)

タイマー間隔のコントロール

フォームには TimerInterval という名前の変数がある。
この値を書き換えてあげれば、繰り返しの停止 or 再開、繰り返し間隔の変更などができる。

'繰り返し処理を止めたい時はこう
Me.TimerInterval = 0 

'繰り返し処理を1秒間隔で再開 or 繰り返し間隔を1秒に変更したい時はこう
Me.TimerInterval = 1000

バージョン

Windows 10 Pro 21H2 OSビルド 19044.2130
Microsoft Access for Microsoft 365 MSO (バージョン 2209 ビルド 16.0.15726.20068) 32 ビット

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?