Process Until End of Recordset

  • Thread starter Thread starter Larry R Harrison Jr
  • Start date Start date
L

Larry R Harrison Jr

I have Access 97 and a database which fills in new values in a
****subform***. It plucks the values from the main form and plugs them into
EXISTING RECORDS in the subform. What I need for it to do is to loop and
keep doing this until it reaches the last recordset of the subform.

The code I have so far looks like this:

' Searches for the 1st entry whose date matches the current date
DoCmd.FindRecord Date, acEntire, False, , False, , True
For n = 1 To 3
Me.sfrSchedule![qty] = Me.txtPartsShift
Me.sfrSchedule![partid] = Me.part_currently_run
DoCmd.GoToRecord , , acNext
Next n

Obviously the n=1 to 3 makes it do it for the 1st 3 lines. The pattern of
the records in the subform is that there are ALWAYS 3 lines for each date.

Instead, what I need it to do is start from where it found the date match
and keep going until it reaches the last record (regardless of the date),
then STOP. Don't keep adding new records.

Tips?

LRH
 
Try

Do Until Me.sftSchedule.Form.NewRecord = True
Me.sfrSchedule![qty] = Me.txtPartsShift
Me.sfrSchedule![partid] = Me.part_currently_run
DoCmd.GoToRecord , , acNext
Loop

I don't have 97 here to test on, so I may be using functionality that didn't exist yet in
97. The idea here is that if your GoToRecord moved beyond the last record then you would
be at a new record and should exit the loop (assuming "Allow Additions" is set to true for
the subform). Another possibility would be to keep remaking a "RecordsetClone" of the
form's recordset and check for EOF (end of file). In 2000 and newer, you can access the
form's recordset directly which would make this much easier.
 
Back
Top