Wow, thanks for the quick responses.
> > 1) What does a .recordcount of -1 mean on an ADO recordset? I've seen
> > sometimes I get this and sometimes I get the real value, but the causing
> > factor isn't obvious to me.
> You have to be in static cursortype to use this property
> rs.Open strSQL, ProspectData.ConnectionString, adOpenStatic
Yes, that was indeed it. What was confusing me is that the cursor type has
to be static, and only static. I was under the impression from other
information, like the link in the first response to my post, that it just
couldn't be forward-only. I was using Dynamic.
> > 2) Does anyone know why I would get the following message trying to
> > a .close on a recordset?
> > 3219: The operation requested by the application is not allowed in
> > context.
This problem was happening in my error handler. (BTW, "on error resume
next" was already set, but this error still got raised. Interesting, eh?)
I heard at a Microsoft MSDN cafe recently that setting a recordset object to
nothing without closing it first causes a memory leak, so I was trying to
close it. But you can't close a recordset when the current record has been
changed. In my case I had tried to insert a duplicate key, so the current
record was a new one that hadn't been updated.
I solved the problem by adding an additional check to my cleanup routine:
Public Sub KillRecordset(ByRef rsRecordset As ADODB.Recordset)
If Not (rsRecordset Is Nothing) Then
If rsRecordset.State = adStateOpen Then
If rsRecordset.EditMode <> adEditNone Then
Set rsRecordset = Nothing
I guess this was one of those duh! ones that should have been obvious to me.