Solved

set db, set recordset .. type mismatch

Posted on 2004-04-22
6
737 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 130 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

630 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