By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,223 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,223 IT Pros & Developers. It's quick & easy.

How walk recset in DAO, do AddNew & return to CurRec B4 AddNew?

P: n/a
MLH
Here's a snippet from A97 HELP on AddNew...

The record that was current before you used AddNew remains current. If
you want to make the new record current, you can set the Bookmark
property to the bookmark identified by the LastModified property
setting.

My own experience is indicating that the newly added record becomes
current during the AddNew processes and REMAINS current after .Update
method runs. This seems true even though the newly added record does
not meet the criteria required in the recordset I'm walking through.

I put a DoEvents stmt after the .Update hoping things would work out.
Is there something else I should be doing after the .Update method
actually writes the AddNew'd record to ensure that I return to the
record that was current before invoking AddNew?
Mar 25 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
MLH <CR**@NorthState.net> wrote:
<snip>
: My own experience is indicating that the newly added record becomes
: current during the AddNew processes and REMAINS current after .Update
: method runs. <snip>

: Is there something else I should be doing after the .Update method
: actually writes the AddNew'd record to ensure that I return to the
: record that was current before invoking AddNew?

Perhaps if you modify the help instruction

"you can set the Bookmark property to the bookmark identified
by the LastModified property setting."

setting it instead to

"the record that was current before invoking AddNew." ?

--thelma

Mar 25 '06 #2

P: n/a
MLH wrote:
Here's a snippet from A97 HELP on AddNew...

The record that was current before you used AddNew remains current. If
you want to make the new record current, you can set the Bookmark
property to the bookmark identified by the LastModified property
setting.

My own experience is indicating that the newly added record becomes
current during the AddNew processes and REMAINS current after .Update
method runs. This seems true even though the newly added record does
not meet the criteria required in the recordset I'm walking through.

I put a DoEvents stmt after the .Update hoping things would work out.
Is there something else I should be doing after the .Update method
actually writes the AddNew'd record to ensure that I return to the
record that was current before invoking AddNew?


How are you adding the record? Via a
Set rst = Me.Recordsetclone?
If so, you can enter
rst.Bookmark = Me.Bookmark

If not, capture the ID, and after the update do a FindFirst
Mar 25 '06 #3

P: n/a
rkc
MLH wrote:
My own experience is indicating that the newly added record becomes
current during the AddNew processes and REMAINS current after .Update
method runs. This seems true even though the newly added record does
not meet the criteria required in the recordset I'm walking through.


A DAO.Recordset remains on the record before the Insert.
An ADODB.Recordset makes the newly inserted record current.

Are you confused as to which you are actually using?
Mar 25 '06 #4

P: n/a
MLH
Oops. Oops. Oops. My bad.

Had an extra .MoveNext in there that was unaccounted
for. More bad programming on my part. Sorry about that.
After taking it out and organizing my code more legibly,
I found that the A97 HELP stmt was correct. The rec that
was current before DOES remain current. So sorry.

Something I did not realize caused me further confusion.
I did not understand that using AddNew in a DAO procedure
would increase the number of records in your recordset as
well as appending a record to the underlying table. Basically,
I was walking the recordset looking for records whose [Field1]
value was "x". When I found one, I was appending an identical
record to the underlying table, but making the [Field1] value "y".
This not only added a record to the underlying table, it added
one dynamically to the recordset. Since I was looping to EOF -
I never got there and had to CTRL-ALT-DEL and end the
process. I ended up having to do away with the Do Until - Loop
and go with a For i=1 to .RecordCount approach. What would
some of you recommend in that situation?
Mar 26 '06 #5

P: n/a
rkc
MLH wrote:
What would some of you recommend in that situation?


One of me would recommend an Append query.
Mar 26 '06 #6

P: n/a
Which of you casts his pearls before swine?

Mar 26 '06 #7

P: n/a
rkc
Lyle Fairfield wrote:
Which of you casts his pearls before swine?


The liberal me.
Mar 26 '06 #8

P: n/a
MLH
Snicker.
One of me would recommend an Append query.


Mar 28 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.