New Library causes change!!!!!!

G

Guest

Hello,

I have used this fragment of code to manipulate the creations of my
recordsets for 5 years without a problem!

However I was always using the following library reference:

Microsoft Acytive-x objects 2.5 library

Today, I have tried the newer version which is:

Microsoft Acytive-x objects 2.8 libtrary

And now, one of the return commands generate an error!
The error is "Runtime error 13" Type mismatch.

It generates this error at the following line:

Set SetRsts = rst1

Here is a more detailed sample of my code. I just don't understand why in
2.5, it does not generate an error, and in 2.8 it does.

Here is the fragment of code, .... it simply is supposed to return a
variable of Recordset type.

-----------------------------------------------------------------------
Private Sub Function1()

Dim rst1Util As ADODB.Recordset
Set rst1Util = OBJ_SQL_Rsts.SetRsts()

'OTHER CODE.......
'.................

End Sub

-----------------------------------------------------------------------------------

Public Function SetRsts() As Recordset

Dim cnn1 As ADODB.Connection
Dim rst1 As ADODB.Recordset
Set rst1 = New ADODB.Recordset
Set cnn1 = CurrentProject.Connection
rst1.ActiveConnection = cnn1

rst1.LockType = adLockOptimistic
rst1.CursorLocation = adUseServer
rst1.CursorType = adOpenKeyset

Set SetRsts = rst1

End Su
 
D

Douglas J. Steele

Your declaration should be

Public Function SetRsts() As ADODB.Recordset

I'm guessing that you have a reference to DAO, as well as the ADO reference.
Your ADO 2.5 reference was probably higher in the list than your ADO 2.8
reference now is.
 

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