Type Mismatch on recordset (1 Viewer)

StephenS

Registered User.
Local time
Today, 10:16
Joined
Mar 24, 2000
Messages
31
I am receiving a "Type Mismatch (Error 13) whenever I dimension a variable as a recordset. For example:

Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb

The error occurs When I try to do a statement like:

Set rst = dbs.OpenRecordset("qryname or SQL", dbOpenSnapshot)

Up until now, I have gotten around it by Dimensioning the recordset as a variant. This work-around has served well up until now. Lately, I've found certain functions like "AbsolutePosition" do not been work with it set up like this. Does anyone have any ideas as to why Access might give me a "Type mismatch" error?


StephenS
 

Travis

Registered User.
Local time
Today, 02:16
Joined
Dec 17, 1999
Messages
1,332
If you are using Access 2000 then set the rst as follows

Dim rst as Dao.Recordset

You may need to add the Dao 3.6 Reference to your project.
 

StephenS

Registered User.
Local time
Today, 10:16
Joined
Mar 24, 2000
Messages
31
Thanks, I'll try it!

StephenS
 

StephenS

Registered User.
Local time
Today, 10:16
Joined
Mar 24, 2000
Messages
31
After working through a chapter in a book on recordsets, I decided to use ADODB recordsets rather than DAO recordsets. The ADODB recordsets are new to Access 2000 and are supposed to be superior (Although either are supposed to work). For ADODB, the code looks like:

Sub CreateRecordset()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.Open "Select * from tblClients"
Debug.Print rst.GetString
rst.Close
Set rst = Nothing
End Sub

Using the ADODB syntax has allowed me to use all of the recordset features and not define them as variants!

There is another object using ADODB that has tended to give me error messages - called the "Connection Object". In my experimenting, it can be left out, though it is supposed to improve performance. The book I got the code from is "Mastering Microsoft Access 2000 develpment", Page 433, by Alison Balter.

StephenS
 

Users who are viewing this thread

Top Bottom