A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using OpenRecordset



 
 
Thread Tools Display Modes
  #1  
Old April 27th, 2004, 02:26 PM
Conor Grogan
external usenet poster
 
Posts: n/a
Default Using OpenRecordset

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
Set rs = CurrentDb.OpenRecordset("Device Table")
With rs

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.
  #2  
Old April 27th, 2004, 02:55 PM
Dan Artuso
external usenet poster
 
Posts: n/a
Default Using OpenRecordset

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" wrote in message
...
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
Set rs = CurrentDb.OpenRecordset("Device Table")
With rs

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.



  #3  
Old April 27th, 2004, 03:07 PM
Sandra Daigle
external usenet poster
 
Posts: n/a
Default Using OpenRecordset

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

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


Conor Grogan wrote:
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
Set rs = CurrentDb.OpenRecordset("Device Table")
With rs

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.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.