When a block is undone via an UNDO statement, RETURN ERROR, or an error condition, all record buffers that were read within that block are cleared.

If a transaction is active when the block is undone, the AVM sets the buffer to the record that the buffer contained before the block started, if any, otherwise the record buffer remains cleared.

The following example code shows a scenario when no transaction is active:
DEFINE BUFFER bOrder FOR Order.
DEF VAR i AS INT.

FIND FIRST bOrder.
MESSAGE "First Order" RECID(bOrder) VIEW-AS ALERT-BOX.

main:
DO ON ERROR UNDO main, LEAVE main:
    FIND LAST bOrder.
    MESSAGE "Last Order" RECID(bOrder) VIEW-AS ALERT-BOX.
    i = INTEGER("a"). // Raise ERROR condition and error 76
END.

// Note that bOrder is not available (so RECID will be ?)
MESSAGE AVAIL(bOrder) RECID(bOrder) VIEW-AS ALERT-BOX.
This is the output from running the code:
If you want to keep the record that was previously in the buffer when an error occurs, make sure to add a TRANSACTION to the outer block. The following example code shows this scenario:
DEFINE BUFFER bOrder FOR Order.
DEF VAR i AS INT.

DO TRANSACTION:
   FIND FIRST bOrder.
   MESSAGE "First Order" RECID(bOrder) VIEW-AS ALERT-BOX.

   main:
   DO ON ERROR UNDO main, LEAVE main:
      FIND LAST bOrder.
      MESSAGE "Last Order" RECID(bOrder) VIEW-AS ALERT-BOX.
      i = INTEGER("a"). // Raise ERROR condition and error 76
   END.

   // Note that bOrder IS now available. 
   // You will see the RECID of the first Order record
   MESSAGE AVAIL(bOrder) RECID(bOrder) VIEW-AS ALERT-BOX.
END.
This is the output from running the code: