The following code is an event on a timer. The code works fine, with one exception.
When the form is refreshed, if there's a new customer, the Wav file is played (that's good). But after the customer is served and there are no customers in the queue, the Wav file is played once more. The Wav file doesn't play every 5 minutes, it only plays one more time, despite no records in the form. In other words, the Wav file is played one more time after the queue is empty.
It appears the form is counting a record but I don't understand why or how to correct the problem. Any help would be appreciated.
_______________________
When the form is refreshed, if there's a new customer, the Wav file is played (that's good). But after the customer is served and there are no customers in the queue, the Wav file is played once more. The Wav file doesn't play every 5 minutes, it only plays one more time, despite no records in the form. In other words, the Wav file is played one more time after the queue is empty.
It appears the form is counting a record but I don't understand why or how to correct the problem. Any help would be appreciated.
_______________________
Code:
Dim VarCount As Variant
VarCount = Forms!frmCustomersInQueue2.Recordset.RecordCount
'Refreshes the screen every 5 minutes; 300000 is equal to 360000 seconds (5 minutes)
DoCmd.Requery
DoCmd.RefreshRecord
'If there's no one in the queue then no sound is played
If VarCount = 0 Then
Else
'If there's one customer then a sound is played
If VarCount = 1 Then
Call PlayWaveFile("C:\Users\Public\Documents\SignInPlus\SignInTool\doorbell.WAV")
Else
'If there's two customers then a sound is played
If VarCount = 2 Then
Call PlayWaveFile("C:\Users\Public\Documents\SignInPlus\SignInTool\doorbell.WAV")
Else
End If
End If
End If
Last edited by a moderator: