Compare records and reset

G

Guest

Could I please ask for help on the following: I have created the code as far
as to open a recordset of data from a table, sorted by username and date of
test. (The table contains records of hearing tests for about 200 users and
will grow quite large over the years). A field called 'baseline' which is a
yes/no is set as Yes for the first record by default. -- I now need to run
code that compares all the future tests for each user and if the field called
'Status' contains two CONSECUTIVE records with 'Abnormal Shift' I need to
reset the field 'Baseline' in the most recent record of the pair to Yes and
change the previous record (wherever that may be, as the position may well
change in the future) back to 'No'.

Any help is much appreciated

Nigel Forge
 
G

Guest

Without writing the code, the basic logic would be: (psuedo code only)

blnFirstAbnormal = False 'Use a boolean variable to know if we found an
abnormal
If rst.baseline = yes Then
save the key field of the record in a variable so we can find it later
to reset it
End If

If rst.status = "AbnormalShift" Then
If blnFirstAbnormal = False Then
blnFirstAbnormal = true 'Found the first abnormal shift
Else
'Save the key to this record, we need to get back to it after we
update the
'original baseline
rst.edit
rst.baseline = True
rst.update
rst.FindFirst 'Use the variable where you saved the original baseline
rst.edit
rst.baseline = false
rst.update
rst.FindFirst 'The record you were on when you found the 2nd abnormal
blnFirstAbnormal = False
end if
End if
rst.movenext
 

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

Top