For Each...Next Statement

  • Thread starter Thread starter gm
  • Start date Start date
G

gm

I have tblReminders with the following fields: ReminderID
(auto number), RemindMeOn(date), Reminder(text), IsItDone
(yes/no). On this table I base form frmReminders with the
corresponding fields. On the On Load event I use the
following code:

Sub Form_Load

For Each RemindMeOn In tblReminders

If RemindMeOn.Value < Date And IsItDone = 0 Then
RemindMeOn.Value = Date
End If

Next

in order to update the RemindMeOn date to the current date
if the IsItDone checkbox is not checked. Unfortunately it
doesn't work. Any clues what I'm doing wrong with the code?

Thanks in advance
 
Doing this through a form seems a bit awkward... this is not what forms are
for! Set up a plain update query and have an autoexec macro run it on
database open, even before you open the form.

HTH,
Nikos
 
Hi,



Probably because Fields IN Reminders refer to the field definition,
not the values of the field.


Try:



CurrentDb.Execute "UPDATE Reminders SET RemindMeOn=Date() WHERE (Not
IsItDone) AND RemindMeOn < Date() ", dbFailOnError




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top