Recordcount Intermittently Working (1 Viewer)

leeby

Registered User.
Local time
Today, 04:18
Joined
Jan 27, 2015
Messages
15
Hi,

I have a DB and make extensive use of public functions to perform various tasks. Using ADO I have a number of functions that open a recordset and return the associated recordset for subsequent processing....in some instances I can use msgbox rs.recordcount and it works as advertised, in other cases it generates an "Object doesn't support this method" issue.

I am opening all recordsets in the same way.....using adOpenDynamic and adlockOptimistic. SQL statement is sometimes generic as in "SELECT * From TableX" or with a specific criteria such as WHERE ABC=Criteria.

The function opening and returning the recordset completes and doesn't close the recordset (had issues with that before) before returning the rs for processing to the calling function.

I know the recordset has at least one record in it because I can msgbox one of the fields and it displays what i expect it to.

I am really puzzled by this......I just don't get what I am doing wrong or missing....

Many thanks for any suggestions

Lee
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:18
Joined
May 7, 2009
Messages
19,175
sometimes, it takes time for all
records to be fetch (ado fetches records
in chunk of blocks). and it does this
asynchrony. you may force to go to the
last record first by issuing rs.MoveLast (this
makes your program wait for a while and
until the fetching is complete).
 

leeby

Registered User.
Local time
Today, 04:18
Joined
Jan 27, 2015
Messages
15
Hi Arnelgp,

Thank you for the quick reply.

I did try rs.movefirst as suggested by other threads and have just tried movelast.

Both of them give the same error message...."Object doesn't support the method"... I am finding this really strange.

This is what I do:

Dim rsproducts as new ADODB.recordset

Set rsproducts = getrecords(Param1, Param2)......

As I have just written this, I realised that I did not use the Set keyword as above, although I do use Dim and Set at the beginning part of the calling function as in....

Dim rsproducts as new ADODB.recordset
Set rsproducts as new ADODB.recordset

Clearly, the returned recordset is actually closed when the called function closes and the recordset object therefore isn't actually persisting and staying open...it is just giving me access to the specific record (there was only one returned anyway)

Thank you for your help, had I not started to type the code i would not ahve noticed this...:)

Thank you
 

Users who are viewing this thread

Top Bottom