OpenRecordSet "Type Mismatch" 
Author Message
 OpenRecordSet "Type Mismatch"

Hello,

I'm trying to do something very simple like just open a
recordset but getting nowhere.

Ultimately the code is designed to populate an array with
data from a table but I can't even get beyond the step:

set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries")

I get the error #13 "Type Mismatch".  Another version of
this code (which should be simple) that I had gotten from
an Access book was:

set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries",
dbOpenDynaset)

However, that last "variable" was also a "killer" since
Access told me it wasn't defined.

I'm new to VBA/Access (but fairly experienced in
programming) ... what am i doing wrong??

Thanks!

Here's the full code:

Option Compare Database

Public varArray As Variant

Public Sub ArrayRecordSet()

Dim rst As Recordset
Dim numRows As Integer
Dim numFields As Integer

Dim j As Integer

Set db = CurrentDb()

Set rst = db.OpenRecordset("ptbl_DeleteQueries")

Debug.Print rst.AbsolutePosition
varArray = rst.GetRows(, , "QueryName")
rst.Close
numRows = UBound(varArray, 2) + 1
numFields = UBound(varArray, 1) + 1

Debug.Print "Fields: " & numFields & " Rows: " & numRows

For j = 0 To numRows - 1

    Debug.Print "dqry_" & varArray(0, j)
Next

End Sub



Mon, 18 Oct 2004 11:37:13 GMT  
 OpenRecordSet "Type Mismatch"
Ray,

I'd say your references are messed up. From any code module, select the
Tools menu, then click References. See if the DAO Object Library is either
MISSING or just not ticked. If either, scoll down and select it. Then hit
OK. That should resolve the problem.

Graham R Seach
Microsoft Access MVP
Sydney, Australia


Quote:
> Hello,

> I'm trying to do something very simple like just open a
> recordset but getting nowhere.

> Ultimately the code is designed to populate an array with
> data from a table but I can't even get beyond the step:

> set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries")

> I get the error #13 "Type Mismatch".  Another version of
> this code (which should be simple) that I had gotten from
> an Access book was:

> set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries",
> dbOpenDynaset)

> However, that last "variable" was also a "killer" since
> Access told me it wasn't defined.

> I'm new to VBA/Access (but fairly experienced in
> programming) ... what am i doing wrong??

> Thanks!

> Here's the full code:

> Option Compare Database

> Public varArray As Variant

> Public Sub ArrayRecordSet()

> Dim rst As Recordset
> Dim numRows As Integer
> Dim numFields As Integer

> Dim j As Integer

> Set db = CurrentDb()

> Set rst = db.OpenRecordset("ptbl_DeleteQueries")

> Debug.Print rst.AbsolutePosition
> varArray = rst.GetRows(, , "QueryName")
> rst.Close
> numRows = UBound(varArray, 2) + 1
> numFields = UBound(varArray, 1) + 1

> Debug.Print "Fields: " & numFields & " Rows: " & numRows

> For j = 0 To numRows - 1

>     Debug.Print "dqry_" & varArray(0, j)
> Next

> End Sub



Mon, 18 Oct 2004 12:08:06 GMT  
 OpenRecordSet "Type Mismatch"
Ray,
In addition you'll need to put DAO in from of the db & rs variables. for
example.
dim db as dao.database
dim rs as dao.recordset

David
Dataovertheweb.com

Quote:
> Hello,

> I'm trying to do something very simple like just open a
> recordset but getting nowhere.

> Ultimately the code is designed to populate an array with
> data from a table but I can't even get beyond the step:

> set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries")

> I get the error #13 "Type Mismatch".  Another version of
> this code (which should be simple) that I had gotten from
> an Access book was:

> set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries",
> dbOpenDynaset)

> However, that last "variable" was also a "killer" since
> Access told me it wasn't defined.

> I'm new to VBA/Access (but fairly experienced in
> programming) ... what am i doing wrong??

> Thanks!

> Here's the full code:

> Option Compare Database

> Public varArray As Variant

> Public Sub ArrayRecordSet()

> Dim rst As Recordset
> Dim numRows As Integer
> Dim numFields As Integer

> Dim j As Integer

> Set db = CurrentDb()

> Set rst = db.OpenRecordset("ptbl_DeleteQueries")

> Debug.Print rst.AbsolutePosition
> varArray = rst.GetRows(, , "QueryName")
> rst.Close
> numRows = UBound(varArray, 2) + 1
> numFields = UBound(varArray, 1) + 1

> Debug.Print "Fields: " & numFields & " Rows: " & numRows

> For j = 0 To numRows - 1

>     Debug.Print "dqry_" & varArray(0, j)
> Next

> End Sub



Mon, 18 Oct 2004 22:14:57 GMT  
 OpenRecordSet "Type Mismatch"
<<put DAO in front of the db & rs variables>>
Only if ADO is also referenced. If you're not using ADO, uncheck it, then
you can refer to the database and recordset objects directly.

Graham R Seach
Microsoft Access MVP
Sydney, Australia


Quote:
> Ray,
> In addition you'll need to put DAO in from of the db & rs variables. for
> example.
> dim db as dao.database
> dim rs as dao.recordset

> David
> Dataovertheweb.com


> > Hello,

> > I'm trying to do something very simple like just open a
> > recordset but getting nowhere.

> > Ultimately the code is designed to populate an array with
> > data from a table but I can't even get beyond the step:

> > set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries")

> > I get the error #13 "Type Mismatch".  Another version of
> > this code (which should be simple) that I had gotten from
> > an Access book was:

> > set rst = CurrentDb.OpenRecordSet("ptbl_DeleteQueries",
> > dbOpenDynaset)

> > However, that last "variable" was also a "killer" since
> > Access told me it wasn't defined.

> > I'm new to VBA/Access (but fairly experienced in
> > programming) ... what am i doing wrong??

> > Thanks!

> > Here's the full code:

> > Option Compare Database

> > Public varArray As Variant

> > Public Sub ArrayRecordSet()

> > Dim rst As Recordset
> > Dim numRows As Integer
> > Dim numFields As Integer

> > Dim j As Integer

> > Set db = CurrentDb()

> > Set rst = db.OpenRecordset("ptbl_DeleteQueries")

> > Debug.Print rst.AbsolutePosition
> > varArray = rst.GetRows(, , "QueryName")
> > rst.Close
> > numRows = UBound(varArray, 2) + 1
> > numFields = UBound(varArray, 1) + 1

> > Debug.Print "Fields: " & numFields & " Rows: " & numRows

> > For j = 0 To numRows - 1

> >     Debug.Print "dqry_" & varArray(0, j)
> > Next

> > End Sub



Mon, 18 Oct 2004 22:21:14 GMT  
 OpenRecordSet "Type Mismatch"
Debug.Print rst.AbsolutePosition varArray = rst.GetRows(, ,
"QueryName") rst.Close numRows = UBound(varArray, 2) + 1 numFields =
UBound(varArray, 1) + 1

--
Posted via dBforums
http://dbforums.com



Tue, 19 Oct 2004 14:24:16 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Openrecordset "Type mismatch"

2. DAO code "Type Mismatch" error

3. set db=currentdb() "type mismatch problem"

4. "Type mismatch" Error

5. Q: SQLForeignKeys gives "Type mismatch"

6. HELP: "Type Mismatch" when opening recordset

7. Handling "Type mismatch" error

8. "Type mismatch" error

9. Runtime error "13" - Type Mismatch

10. VB5 "type mismatch" problem

11. MyCriteria (database search) "Type Mismatch"

12. Q: SQLForeignKeys gives "Type mismatch"

 

 
Powered by phpBB® Forum Software