DIM dbs as database (missing reference?) (1 Viewer)

homer2002

Registered User.
Local time
Today, 22:54
Joined
Aug 27, 2002
Messages
152
Hi

i'm has just upgraded to access 2002 and am having problems with the VBA
to be presise i'm trying to implment the line

DIM dbs as database
or
DIM dbs as dao.database

for some reason access 2002 won't find database in the auto text
and it doesnt like it as a type

what am i doing wrong???
 
Last edited:

homer2002

Registered User.
Local time
Today, 22:54
Joined
Aug 27, 2002
Messages
152
Hmm

ok I've found the Microsoft DAO reference and now
i can can get the autofill word 'database' when I SET it.

Now when I try to pull out a recordset ....

Set rst = dbs.OpenRecordset("SELECT * FROM tbl1")

all I get is an error message TYPE MISMATCH (runtime 13)


Do i need to reference anything else??
 

RoyVidar

Registered User.
Local time
Today, 23:54
Joined
Sep 25, 2000
Messages
805
Since you are a bit secretive about your code:

dim dbs as dao.database
dim rst as dao.recordset
set dbs=curentdb
set rst=dbs.openrecordset("select * from tbl1")

or substitute the two last with

set rst=currentdb.openrecordset("select * from tbl1")

- guessing the recordset wasn't explicitly declared
 

homer2002

Registered User.
Local time
Today, 22:54
Joined
Aug 27, 2002
Messages
152
Since you are a bit secretive about your code:

dim dbs as dao.database
dim rst as dao.recordset
set dbs=curentdb
set rst=dbs.openrecordset("select * from tbl1")

or substitute the two last with

set rst=currentdb.openrecordset("select * from tbl1")

- guessing the recordset wasn't explicitly declared
__________________

Cheers for the help

as much as i'd like to be on a project worth keeping secret, the truth is there is no code yet.

This is the first form i am trying to code and all I am trying to do is open a recordset



my entire code is as follows

dim dbs as database
dim rst as recordset
SET dbs = currentDb
SET rst = dbs.OpenRecordset("SELECT * FROM tbl1")


I get a Type mismatch error on the SET rst =...... line

I have tried

dim dbs as DAO.database

but access wont pick up on the DAO. part of the decleration
(i.e. it wont give me any of the properties like .database or .recordset)

can someone help as I really dont know what i'm doing.
I thought it should just work, but it aint :-(

PLEASE HELP ME
 

ghudson

Registered User.
Local time
Today, 17:54
Joined
Jun 8, 2002
Messages
6,194
Not sure if there is a difference but try this line instead...

Set rst = dbs.OpenRecordset("tbl1")
 

Cynoclast

Registered User.
Local time
Today, 14:54
Joined
Nov 4, 2004
Messages
11
My guess is you've got ADO listed as a reference above DAO. So when you declare your recordset it's making an ADO recordset and you're trying to shove a DAO recordset into it..which won't work.

Be careful, if you have both ADO and DAO listed in your references the one listed first takes precedence

If you plan on using both, declare your ambiguous objects explictly, such as
Dim db As DAO.Database
Dim rs As DAO.Recordset
dim rs2 As ADODB.Recordset '(ADO doesn't have Database objects!)

I think RoyVidar said this, you just didn't pick up on it.
 

Users who are viewing this thread

Top Bottom