Alarm Code error

K

Kay

Hi

I have created a reminder for my project, I gave created an alarm table
with the fileds Alram Date, alarm time and alarm message. I have used
the following code in the on timer event() which checks the table to
see if any alarm times match the current time so it can set it off.
I am getting a compile error - "Next without For" and the code "Next i"
is highlighted. my code is as follows

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

Can anyone please help

Very much appreciated
 
M

Maus

Hi Kay,

How about moving to the next record? before the Next i statement add:
rst.movenext

Maus
 
K

Kay

Hi

It loop should look through all the records, although I tried that and
it still has the same error
 
D

Dirk Goldgar

Note to readers: this question was reposted in this newsgroup --
subject "Problem with code" -- and is being handled in more detail in
that later thread.
 

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

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

Top