Using OpenRecordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button on a form called "command9". When this is clicked I want to go through all the entries of a table called, "Device Table". I using the following code:
Private Sub Command9_Click()
Dim rs As Recordset
Do Until .EOF

I am getting the following error, "Runtime error '13': Type Mismatch". Have I declared rs wrong? How can I over come the problem? Can this be run on queries as well as on tables?
Any help would be much appreciated.
 
Hi,
Both the DAO and ADO libraries have recordset objects.
You obviously have references to both so you'll have to declare your rs
like:
Dim rs As DAO.Recordset

HTH
Dan Artuso, MVP

Conor Grogan said:
I have a button on a form called "command9". When this is clicked I want
to go through all the entries of a table called, "Device Table". I using the
following code:
I am getting the following error, "Runtime error '13': Type Mismatch".
Have I declared rs wrong? How can I over come the problem? Can this be run
on queries as well as on tables?
 
Hi Conor,

I am guessing that you are using Access 2000 or 2002 and that you're missing
the reference to the DAO Library. Open the module in the Visual Basic Editor
(VBE) then click Tools->References. Make sure that the Microsoft DAO 3.x
Object Library is checked. You might also want to check this article details
and info on how to fix the problem:

http://www.mvps.org/access/bugs/bugs0031.htm

I would also recommend that you fully declare your variables including the
library name from which they come. By disambiguating your declarations,
Access doesn't have to guess which Recordset you want (the ADO and DAO
libraries both have recordset objects). This also makes your code more
readable and somewhat more efficient. Here's an example:

dim rst as DAO.recordset
 
Back
Top