J.J.,
Hi. Good News...I think I have
found your problem. Testing the
code that you wrote in your "Take
2" email, everything looks just fine.
It took me a while to recreate your
error, but after some time I finally
did it.
My guess is that you have a reference
library included in your VB project
for any version of:
Microsoft ActiveX Data Objects 2.x Library
If you are not using ADODB or ADODC
in any way in your project removing
this reference will solve your problem.
(Drawing an ADODC on any form in your
project will automatically include
this library in your projects).
If you are using ADO somewhere else in your
project the problem can be solved by changing
your Example2 to
Private Function Example2(...) As DAO.Recordset
The error you are experiencing is caused
by the fact that VB does not explicitly
know what Recordset means in your
declaration. When this occurs, VB IDE
will start from the top of your reference
library list (click on Project->References)
until it finds a match for Recordset.
In your case, my guess is that your
ADO library is listed above your DAO library.
This will declare the return of Example2
as an ADODB.Recordset and of course
you will get a type mismatch.
This is one of those rare occasions where
the order in which the libraries are listed
makes some difference.
Suggestion: In any project that I develop
I always explicitly declare any database
objects, even when I am using just DAO or
ADO.
EX:
Dim adoConn as ADODB.Connection
Dim myDB as DAO.Database
I do this because, if there is ever a need in
the future to use both technologies (or a future
technology not developed yet) I can easily
add DAO or ADO references to the program
without fear that it will break something
else in the code.
Please let me know if this was the solution.
Cardyin
--------------------------------------
Cardyin Kim
System Analyst - Information Services
San Antonio Community Hospital
ckim@s... (xxx)xxx-xxxx
--------------------------------------