Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

set db, set recordset .. type mismatch

Posted on 2004-04-22
6
Medium Priority
?
751 Views
Last Modified: 2012-06-22
hello i'm back :)
i'm trying to open a recordset, database connection.

i have a form, with a button, i press the button and go to a sub.

private Sub bt_blaat_Click()

'I tried adding
' Dim wsSessie as Workspace
' Set wsSessie.OpenDatabse(CurrentDb)
'doesnt make a difference

Dim db As Database
Dim rsRead As Recordset

Set db = CurrentDb

Set rsRead = db.OpenRecordset("tablename", dbOpenTable)
rsRead.MoveLast
rsRead.MoveFirst

end Sub

error: type mismatch

("typen komen niet overeen")

does anyone have any idea of what i'm doeing wrong?
all help is welcome...




0
Comment
Question by:mazzl
6 Comments
 
LVL 10

Expert Comment

by:RichardCorrie
ID: 10887863
try
Set rsRead = db.OpenRecordset("tablename", dbOpenDynaset)

I guess your table "tablename" is a linked table; for some reason Access will not open a linked table with dbopentable but will with dbOpendynaset - they do the same thing!!

Richard

0
 
LVL 1

Accepted Solution

by:
dssdb earned 520 total points
ID: 10887922
'dim you recordset as DAO. Be sure to include a reference to DAO in your references.

Dim rsRead As DAO.Recordset
0
 

Author Comment

by:mazzl
ID: 10887934
Tried it.."Set rsRead = db.OpenRecordset("tablename", dbOpenDynaset)"
same error
brrr i already did this once succesfull in an other program and it worked just fine :S

"tablename" is the name of the table.. it's really called "advies_recept_middel_koppel"

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mazzl
ID: 10887954
can somebody explain the need for DAO.etc.. to me, when do i need to use this?
i already had some problems with this.

what i think now is that Dao is a library of something, but for what is it etc?
0
 
LVL 1

Expert Comment

by:dssdb
ID: 10888046
It's because the RECORDSET object is used by 2 different libraries: ADO and DAO.  If you don't put DAO before your declaration it'll assume you're trying to use the ADO recordset object.  Statements like OpenRecordset are not supported by ADO.

Alternatively you could have removed the ADO reference from your project.  Then Access would not have been confused.


0
 

Expert Comment

by:stratcat35
ID: 11154672
Defining the Recordset as DAO did work for me.  One difference, however, is that I defined the OpenRecordSet statement with no dbDynaSet, dbSnapShot, etc. parameters: Set Rec_Set = CurrentDb.OpenRecordset(strQuery)

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question