Link to home
Start Free TrialLog in
Avatar of mazzl
mazzl

asked on

set db, set recordset .. type mismatch

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...




Avatar of RichardCorrie
RichardCorrie

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

ASKER CERTIFIED SOLUTION
Avatar of dssdb
dssdb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mazzl

ASKER

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"

Avatar of mazzl

ASKER

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?
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.


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)