[AccessD] Access crashes when assigning empty recordset
Fred Hooper
fahooper at gmail.com
Tue Sep 11 14:55:08 CDT 2018
I'm debugging an A2003 front end to a SQL Server 2017 back end. All data
sourcing is though stored procedures, using ADO; all associated code is
centralized. I'm filling a subform; which of two subforms is filled
depends on a value in the parent form. The unused subform is disabled
and hidden.
* As I move through the records of the parent form the subforms fill
correctly.
* When I add a new record of each type, both work correctly.
* When I attempt to change the type for a record the crash occurs.
o The code to do so is the same code as the first two items above
o Here are the steps:
+ Create the recordset -- works properly
+ Code that assigns the recordset:
frm.RecordSource = ""
Set frm.Recordset = Nothing
If rst.State = adStateOpen Then
Set frm.Recordset = rst -- it crashes here!
rst.CLOSE
End If
Set rst = Nothing
+ These disconnected recordsets work perfectly everywhere (so
far) except for this; if they are created with optimistic
locking they are editable and can be appended to, if read
only they are that. All use a client side cursor and are
loaded forward only -- but navigable in the forms.
+ It is crashing only on loading an empty recordset, but with
anything except switching the value in the parent form empty
recordsets load without issue. The changing value in the
parent form isn't referenced anywhere in the loading code;
it just affects which code is executed.
+ In looking at the recordset at the crash point it has (1)
zero records; (2) EOF = True; and, (3) BOF = True -- all the
expected values.
+ An identical empty recordset in the master record created
with the value I'm changing to has records added without any
problems.
* In writing this I realized that I can write a stored procedure to
make the change in the database and reload the form. I'm confident
that will work, but it seems kludgy.
Any ideas?
TIA,
Fred
More information about the AccessD
mailing list