New Record pointer

  • Thread starter Thread starter msnews.microsoft.com
  • Start date Start date
M

msnews.microsoft.com

Hello,
I am using my own navigation buttons on a form and displaying the record
posions on a label e.g. "x of total records" I am using a bound table .
whenever i add a new record it goes to the last of recordset , is there any
way to display it at the same location where i am adding it.like adding in
order(ascending). I am using me.requery but it makes me reach at 1st record
while i want to remain at the same locatio where i was. also i am tiered of
error "not a valid book mark"
pls tell me how i should handle this.
thanks
 
Records are added to the end of the open recordset (which
doesn't have anything to do where they are actually stored
or where they will appear after a requery). This is to
minimize the jumping around of the recordpointer that
would happen if records were inserted and then the
recordset resorted. Most people prefer this behaviour.
It is also more convienent when you are adding multiple
rows. Requerying a recordset causes the query to be re-
executed. That is why when you requery, your record
pointer moves to the first item in the set.

Bookmarks are only valid within a particular recordset.
They mark a record's ordinal position within the set.
When you requery, you potentially change the record order,
so any bookmarks from prior to the requery would be
invalid. If you want to insert a record, requery, and
then reposition on the inserted record, you need to save
the primary key of the inserted record. Then you can use
the find command to move to that record.
 
store the offset before requerying
check out the goto record command

maybe docmd.gotorecord or something

do this after requerying, using the stored offset
 
This should be pretty straight forward.

When you add a record, theoretically it has value associated with the
primary key of the underlying table or recordset.

So step wise it might look like this:

1.) Form is filled with data, and committed (i.e. saved)
2.) Capture values of the primary key values into variables for the record
just created.
3.) Requery the form
4.) Create a recordset clone
5.) Use the find method to locate the record using the primary key values
stored in variables in item 2
6.) Capture the bookmark into a variable after a successful find.
7.) Set the form bookmark = to the value of the bookmark variable.
 
Back
Top