Alarm message

K

Kay

Hi
I have created a reminder in my database. I have created a reminder
table with the fields alarm id, alarm date, alarm time and alarm
message. I use a form to enter the alarm details into my table. I have
used the following code in my form timer event:

If Me.AlarmDate = Date And Me.AlarmTime <= Time() And Me.Reset = False
Then
MsgBox ("A Job is Due") & vbCrLf & _
("ALARM ID = ") & AlarmID & vbCrLf & ("ALARM MESSAGE = ") &
AlarmMessage & vbCrLf & ("Please tick the reset box on the alarm form
to reset the alarm")

If the alarm time is passed, the alarm message is shown after every
update so I have used a rest checkbox to stop an alarm that already has
gone off. The problem I have is that a message is only shown for an
alarm that the focus is set on. By that I mean If alarm id 123 is
displayed in the form, then the alarm message will only be shown for
that alarm when the time has come. What I need it to do is to shown
the message for any alarm not just the one that is being viewed.
I just hope Im clear because I think im beginning to confuse myself
now. Any help will be much appreciated
 
A

Arvin Meyer [MVP]

You might try building a recordset and walking through it like (aircode):

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim i As Integer

Set db = CurrentDB
Set rst = db.OpenRecordset("Select * tblAlarms Where Reset = False",
dbOpenSnapshot)

rst MoveLast
rst.MoveFirst
For i = 1 To rst.RecordCount
' Your code here
Next i
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
K

Kay

Hi
I tried this code but it is not recognising the variables
Dim db As DAO.Database
Dim rst As DAO.Recordset

The message is: User-Defined type not defined

Any ideas
 
K

Kay

Hi Arvin

I compiled the code now and it shows an error at the end of the for
loop by....... Next i
The error is Compile Error - "Next without For"

Ive double checked this code against other for loop code and it seems
to be fine so I cannot figure out why it is showing this error.

Please could you help
 
K

Kay

Hi Arvin

I have got the for i = 1 to rst.RecordsetCount statement. Here is my
entire code:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("Select * AlarmTable Where Reset = False",
dbOpenSnapshot)
rst.MoveLast
rst.MoveFirst

For i = 1 To rst.RecordCount
If Me.[AlarmDate] = Date And Me.[AlarmTime] <= Time() And Me.[Reset] =
False Then
MsgBox ("A Job is Due") & vbCrLf & _
("ALARM ID = ") & AlarmID & vbCrLf & ("ALARM MESSAGE = ") &
AlarmMessage & vbCrLf & ("Please tick the reset box on the alarm form
to reset the alarm")

Next i

Your help is much appreciated Arvin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Reminder Problem 3
Alarm Code error 3
Alarm form 6
Problem with code 10
Alarm in access 1
Code error 4
Outlook email -- A program is trying to automatically send e-mail onyour behalf . . . 8
Reminder Problem 1

Top