Hello,
Sorry I'm not answering faster but I am not on the machine all the time.
To "shut off" the alarm I created a Yes/No type field in the table of appointments.
I called it AlarmAnswered.
So the table has:
Field Name DataType
EventName Text IDs the event
EventDt DateTime date and time of the appointment
Warning Text warning in day fractions
AlarmAnswered Yes/No shut off
You may want a record ID too with Autonumber
Build your alarm form with this for a RecordSource
SELECT TblEventAlarm.EventDt, TblEventAlarm.Warning, TblEventAlarm.AlarmAnswered, TblEventAlarm.EventName, CDate([EventDt]-Eval([Warning])) AS Expr1
FROM TblEventAlarm
WHERE (((TblEventAlarm.AlarmAnswered)=False))
ORDER BY CDate([EventDt]-Eval([Warning]))
WITH OWNERACCESS OPTION;
This will put the appointment that has the most pressing alarm time "first in line". It will also ignore any record that you have elected to "shut off" by checking the AlarmAnswered checkbox. Those records "disappear" from your form. They will still be in your table but not available to the form.
I set the form's Timer to 60000 - the exact number doesn't matter - just not so low as to make it "go off" too often, but to "check" often enough.
On the OnTimer event I put this:
Private Sub Form_Timer()
Dim Str1 As String
' the next four lines of code just run
' a shutoff I put on the form to
' build it with less hassel
' just an option group with two buttons
' one is valued at 0
' one is valued at 1
' this just shuts it off if the option buttons are set to 1
If OptOnOff = 0 Then
Else
Exit Sub
End If
Str1 = EventName & " at " & EventDt
If Now() > TxtDt - Eval([CboDtA]) Then
MsgBox "Alarm for " & Str1, , Nz(EventName, "No Name")
End If
End Sub
On the form I have controls for each field in the recordset.
ControlName: ControlType: Bound to:
TxtEventName Textbox EventName
ChkAlarmAnswered Checkbox AlarmAnswered
TxtDt TextBox EventDt
CboDtA Combo Warning
The combo is as described before - Value List - 2 columns - " 20;20 days;10;10 days;5;5 days;2;2 days;1;1 day;(12/24);12 hours;(6/24);6 hours;(3/24);3 hours;(3/48);90 minutes;(1/48);30 minutes "
Bound Column is 1 - column widths 0,2 .
Your form will open with the earliest and most pressing appointment as the current record. It will run the above code repeatedly, and will pop up a messagebox when an unchecked alarm deadline is passed.
Each control you can edit that could change the alarm time sequence should have an after update event that forces the form to requery so that once again the first event in line becomes the current record and the alarm will "ring" first for the most urgent appointment. Add these:
Private Sub AlarmAnswered_AfterUpdate()
Me.Requery
End Sub
Private Sub CboDtA_AfterUpdate()
Me.Requery
End Sub
Private Sub ChkAlarmAnswered_AfterUpdate()
Me.Requery
End Sub
Private Sub TxtDt_AfterUpdate()
Me.Requery
End Sub
Is this any help?
C