After Adding a New Record it remains the Last Record in Recordset

  • Thread starter Thread starter owibach
  • Start date Start date
O

owibach

When using AddNew in DAO to add a new record to a Recordset it remains the
last record although the table is indexed and if the table is opened the new
record is positioned correctly.
 
As I understand it the recordset is loaded once when you open, say, a form
bound to the recordset, but is not reloaded unless you specifically requery
it. Until it is requeried new records will appear to be at the end of the
recordset.
The same thing applies if you are using a query rather than a table as the
recordset. A query would give you more flexibility in ordering the records.
 
Thanks for yout suggestion. I have based the recordset on a query and am able
to position the new record correctly using "requery". I bookmarked the new
record but the bookmark is not recognised after the requery and consequently
I am at he first record again. Any thought about going to the new record ?
 
You have to capture the a unique value in the current record, usually the
primary key field. Then after the requery, reposition to the record.

Dim lngPrimeKey As Long

lngPrimeKey = Me.PrimeKeyControl
Me.Requery
With Me.RecordsetClone
.FindFirst "[PrimeKeyField] = " & lngPrimeKey
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
 
Back
Top