Here is a chunk of code that works for an individual record. It
evaluates dates and checks or unchecks boxes as it goes along. It may
not be pretty but it works. What my problem is that I need it to
evaluate all the records(200+) in my db and change those which need
changing. Having to do it individually would defeat the purpose of
developing this code. What I would like to be able to do is either 1.
Open the db push a button and all the records update Or 2. Have it
update automatically each time the db opens. It really only needs to be
done once a day so I'm leaning towards #1. So I figure I need to be able
to loop this code through all the records until the last record then
stop. So heres the rub, How do I do that? Should this code be put in a
Module? My db opens up to a FORM called "TITLE PAGE" the records which
require updating are manipulated through a Second FORM called "MASTER
PAGE" I would like to be able to update the records at the TITLE PAGE.
It currently works with the push of a button on the MASTER PAGE but only
updates one record at at time, push the button it updates, manually
select new the record, push the button it updates, manually select new
the record... This is not how it should work. I would like it to work
from the TITLE PAGE Push the button updates all the records and I'm
done.
Private Sub test2_Click()
Dim db1 As Database
Dim rst As Recordset
Set db1 = DBEngine(0)(0)
Set rst = db1.OpenRecords et("Pers_Landed ", dbOpenTable)
Set rst = db1.OpenRecords et("Pers_Postin g", dbOpenTable)
Set rst = db1.OpenRecords et("Pers_Medica l", dbOpenTable)
Set rst = db1.OpenRecords et("Pers_Other_ Data", dbOpenTable)
Do While rst.BOF = False And rst.EOF = False
If (RFD) <= DATE Then
SAILING = True
End If
If (COURSE_OUT) <= DATE Then
COURSE = True
SAILING = False
End If
If (COURSE_IN) <= DATE Then
COURSE = False
SAILING = True
End If
If (COURSE) = True Then
LCA = False
SAILING = False
End If
If (LANDED_OUT) <= DATE Then
LCA = True
SAILING = False
End If
If (LANDED_IN) <= DATE Then
LCA = False
SAILING = True
End If
If (LCA) = False And _
COURSE = True Then
SAILING = False
End If
If (Start_Leave) <= DATE Then
CRS = True
SAILING = False
End If
If (Stop_Leave) <= DATE Then
CRS = False
SAILING = True
End If
If (START_DATE) <= DATE Then
MEDICAL = True
End If
If (STOP_DATE) <= DATE Then
MEDICAL = False
End If
If (COS_OUT_DATE) <= DATE Then
P_IN = False
ATP = False
SAILING = False
P_OUT = True
End If
rst.MoveNext
Loop
End Sub
*** Sent via Developersdex
http://www.developersdex.com ***