Hi Michael,
Basically what I want to do is move through a recordset, test date fields in each record with date fields in the previous record
where the records belong to the same personthen depending on the date difference, update another field.
This is hospital admission data and I am checking for patients re-admitted within a certain time period. If they are I want to flag the record as a "Readmission", if not, leave it blank.
The process I'd envisaged was something like:
1. Sort query on PatientID, AdmissionDate
2. Read first record, put PatientID, AdmissionDate and DischargeDate into variables PatID1,ADate1 and DDate1
3. Move to next record and read, put PatientID, AdmissionDate and DischargeDate into variables PatID2,ADate2 and DDate2
4. Compare PatID2 with PatID1, if different then move to next record, if the same then compare the date difference between ADate2 and DDate1. If the difference is less than a particular number e.g. 8 days then update the field "Readmission" to "Yes". If the second admission is more than 8 days after the first discharge date then either leave "Readmission" blank or update to "No".
5. Reset PatID1, ADate1 and DDate1 with the values in PatID2, ADate2 and DDate2. Move to next record and loop from Step 3 to EOF.
I don't believe I can do the update part just from a query as the update depends on the comparison of dates from the previous record (if ther is a way I'd like to know!)
I would be interested to hear if there is a better strategy but the fundamental thing I need to know is:
Once I have moved to the first record - what is the syntax of the code that will read the PatientID, AdmissionDate and DischargeDate in order to put them into the variables? This was the easy bit I alluded to and I'm embarrassed to say I'm not sure how to do it when working with a recordset

.
Any advice would be gratefully received.
Cheers
Morris