Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does "dim dbs as database" not work

Status
Not open for further replies.

rperre

Programmer
Jan 25, 2005
39
US
Hey, I used to program vb in school and at work a couple of years ago and I always used the following code to create a recordset so I could fill in data in tables, validate, etc...

Dim dbs as Database
Dim rst as recordset

set dbs=currentdb
set rst=dbs.openrecordset("table_name")

rst.findfirst..... etc.. etc.. etc..

but now I'm getting an error because it does not recognize the Database as an object, I'm using ms office XP (2003 I think) which has vb 6.3

What's wrong with this, did vb change this in the last years?
What should I do to get the same recordset so I can work with the data?

thank you,

Richard
 
Tools | References - add Microsoft DAO 3.# Object Library to your references.

Also be explicit in the declarations:

[tt]dim dbs as dao.database
dim rst as dao.recordset[/tt]

Roy-Vidar
 
another great answer, thank you very much, I was missing a lot of vb stuff without that reference on.

I'll implement the dao in my codes from now on, thanks for the tip

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top