no current record error

  • Thread starter Thread starter Dave Bradshaw
  • Start date Start date
D

Dave Bradshaw

I have a form with a subform that shows records in a continuous form.
By the side of the record on the subform is a button which the user
can click to modify the record. So the display on the subform is a
table of records, with a button beside each record.

The button works fine except in one instance. The problem is when the
user clicks on the button for the first record on the subform (and it
carries out its actions) and another record is selected on the master
form, and the records on the subform are changed. If the user again
clicks the button for the first record on the subform (as it is
ordered on the subform), a "Run-time error '3021' No current record."
error is generated. But if the user clicks on the button for the
second record, no error is generated. If the user clicks into another
record and then back into the original record, the button works OK,
and it works OK if the second or subsequent records are repeated.

I can't understand why Access does not see the first record as being
the current record, unless the cursor is moved from another record.
Can anyone explain this behaviour, or at least give me a work around?

Thank you
 
The main form has a combo box that allows the user to select a new
record. The form does not allow the user to create new records.

The "no current record" error relates to the data on the subform. When
the user clicks the button, the code gets the contents of one of the
fields in the current record, and depending upon the contents of that
field it carries out one of two procedures. The error is raised by a
statement containing me!FieldName.

The subform appears to have been refreshed by when the user changes
the record on the master form, that is the text boxes show the data
relevent to the new record.
 
My last post is misleading. I can access the record data held in the
text box on the form. The error is raised after I have set a recordset
to the form's recordset, and I try to access the record in the
recordset.

So the problem appears to be that the subform has cleared its
recordset of the old data, displays the new data, but does not update
its recordset to the new data until the cursor is moved to a different
record on the form.
 
Back
Top