Re: Updating all records in a recordset

From: Marc (mPAMpaisl_at_optusnet.com.au)
Date: 05/11/04


Date: Wed, 12 May 2004 09:34:30 +1000

Answers inline
> The following code returns multiple records to the
> recordset. How do I update each record in the recordset
> with the value of lngNext?
>
> Set MyDb = CurrentDb
> Set qdf = MyDb.QueryDefs("QueryBlockAv")
> For Each prm In qdf.Parameters
> prm.Value = Eval(prm.Name)
> Next prm
> Set rs = qdf.OpenRecordset(dbOpenDynaset)
    if rs.RecordCount = 0 then
    ' no records processing
    goto eventExit
    end if

    while rs.EOF = false
> rs.Edit <== never actually used this command, not really necessary
> rs![Booking ID] = lngNext
> rs.Update
    rs.MoveNext
    wend
> rs.Close
> Set rs = Nothing
>
> This I believe only updates the first record. Is there a
> way of looping through each record in the set and also
> when do I know that I've got to the end?

HTH
Marc