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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|