subform RecordsetClone: No Current Record

  • Thread starter david epsom dot com dot au
  • Start date
D

david epsom dot com dot au

I have code like this in the form before update event:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Call WriteRecordToAuditTrail(Me.RecordsetClone, "DP", "qry_Rate", "Modify
Before")

End Sub


All the Audit function does is copy the data from the current record.
Sometimes I get a 'No Current Record' error.
If I break on error, I can see that the recordset clone does not have a
current record.
The subform is in datasheet view. There is no separate save button: this
subform automatically saves when the record looses focus.


The recordset is NOT empty, I was NOT at a new record, I just changed the
number in one field. Me.RecordsetClone is supposed to be initialised to the
current record, I have a current record which I have just edited. The error
is not 100% repeatable, sometimes it just goes away.


Any insight?

(david)
 
M

Marshall Barton

david said:
I have code like this in the form before update event:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Call WriteRecordToAuditTrail(Me.RecordsetClone, "DP", "qry_Rate", "Modify
Before")

End Sub

All the Audit function does is copy the data from the current record.
Sometimes I get a 'No Current Record' error.
If I break on error, I can see that the recordset clone does not have a
current record.
The subform is in datasheet view. There is no separate save button: this
subform automatically saves when the record looses focus.

The recordset is NOT empty, I was NOT at a new record, I just changed the
number in one field. Me.RecordsetClone is supposed to be initialised to the
current record, I have a current record which I have just edited. The error
is not 100% repeatable, sometimes it just goes away.


The RecordsetClone is not synchronized with the form's
recordset, which is very handy when you want to add a record
programatically.

To make the recordset clone's current record the same as the
form's current record, use

Me.RecordsetClone.Bookmark = Me.Bookmark

The later versions of Access (A2K+) also have a Recordset
property. I haven't had a use for it myself, but I believe
it is the form's actual recordset, so it would be
synchronized. Check Help to see if you'd prefer to use it
instead.
 
D

david epsom dot com dot au

"RecordsetClone Property"
"When a new Recordset object is opened, its first record is the current
record. "

It then goes on to say:

"If you one of the Find method or one of the Move methods to make any other
record in the Recordset object current, you must synchronize the current
record in the Recordset object ..."


That is a new Recordset object, I haven't used the Find method or one of the
Move methods.


So if the help file is not correct, I guess you can call that a either a bug
or a documentation error.




(david)
 
M

Marshall Barton

IMHO, it's a documentation error. Least wise, I've never
tried to rely on whatever information that sentence intended
to convey :-\

Did setting the bookmark solve your problem?
 
D

david epsom dot com dot au

Did setting the bookmark solve your problem?

It's hard to say. I only occasionally see the problem, so
not seeing any error message is par for the course.

(david)

Marshall Barton said:
IMHO, it's a documentation error. Least wise, I've never
tried to rely on whatever information that sentence intended
to convey :-\

Did setting the bookmark solve your problem?
--
Marsh
MVP [MS Access]

"RecordsetClone Property"
"When a new Recordset object is opened, its first record is the current
record. "

It then goes on to say:

"If you one of the Find method or one of the Move methods to make any other
record in the Recordset object current, you must synchronize the current
record in the Recordset object ..."

That is a new Recordset object, I haven't used the Find method or one of the
Move methods.

So if the help file is not correct, I guess you can call that a either a bug
or a documentation error.

(david)


to
the
 

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