No Current record error

D

dhstein

I am adding a new entry in a table with .AddNew followed by .Update
Further down in the program, I want to modify a field in that record. What
is the syntax to refer to that record?

I tried rsMytable.LastUpdated.Edit

Thanks for any help with this
 
D

Dirk Goldgar

dhstein said:
I am adding a new entry in a table with .AddNew followed by .Update
Further down in the program, I want to modify a field in that record.
What
is the syntax to refer to that record?

I tried rsMytable.LastUpdated.Edit

Thanks for any help with this


The .LastModified property returns a bookmark, not a reference to the actual
record. Try this:

With rsMyTable
.Bookmark = .LastModified
.Edit
' ... set various field values ...
.Update
End With
 
D

dhstein

Thanks Dirk. Apparently it also works when I do :

rsMyrecordSet.LastUpdated

rsMyRecordSet.Edit

......
......
rsMyRecordSet.Update
 
D

Dirk Goldgar

dhstein said:
Thanks Dirk. Apparently it also works when I do :

rsMyrecordSet.LastUpdated

rsMyRecordSet.Edit

.....
.....
rsMyRecordSet.Update


I don't see how that could possibly work! A recordset's LastUpdated
property is just the date/time the table or object was last mupdated.
Invoking it as though it were a method would have no effect on the
positioning of the recordset.

Maybe you meant "LastModified", not "LastUpdated". But that also would have
no effect on the position of the recordset. As I said, it simply returns a
bookmark that can be used to position the recordset by assigning it to the
recordset's Bookmark property.

You may *think* your recordset is being positioned by the code above, if it
happens that the recordset is already positioned at the record you wanted.
But normally that would not be the case.
 
D

dhstein

Dirk,

I'm sure you are correct. What I had done was delete all records in a
table and then create new records based on values in another table. So I did
an AddNew for the first record, but when I tried to modify it I got the error
"No current record" So by doing an rsMyTable.LastUpdated I set the pointer
to the last record I updated which was also the record I wanted. Thanks.
 
D

Dirk Goldgar

dhstein said:
I'm sure you are correct. What I had done was delete all records in a
table and then create new records based on values in another table. So I
did
an AddNew for the first record, but when I tried to modify it I got the
error
"No current record" So by doing an rsMyTable.LastUpdated I set the
pointer
to the last record I updated

Except that you didn't. Without seeing your real code, I can't say what
caused your problem in the first place, nor how you changed things so as to
avoid that problem, but I assure you that executing "rsMyTable.LastUpdated"
would have no effect whatsoever on the recordset's position.
 
D

dhstein

Dirk,

My apologies. I went back to check the code. I see I did a .MoveLast
which for my purposes did the trick.
 
D

Dirk Goldgar

dhstein said:
My apologies. I went back to check the code. I see I did a .MoveLast
which for my purposes did the trick.


Ah, that explains it. No apologies necessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top