Accessing tables via VBA

D

Dan Artuso

Hi,
You need to set a reference to the DAO library.
From the VB editor go to Tools->References
and check the DAO library.
You will then have all the familiar objects you are
used to.
 
K

Kendrick

I am attempting to upgrade a access database from 1997 to
2002. In Access 1997 I used a series of steps to be able
to view data and edit data in a table from within a
module. I would create a database object set it to
CurrentDb and then use the openrecordset method to set a
recordset variable to the table I wanted to work with. So
far I cannot figure out what a comparable method is in
Access 2002. The database object doesn't even exist
anymore. I hope someone can make sense of this and give
me a few pointers as to how to work with tables from VBA.

Thanks
 
K

Kendrick

Hi,

Thanks for the information about the DAO Library. I
found that and clicked on it so that I now have the
database object. However, my openrecordset method still
isn't working. As far as I can tell I am using the same
syntax as exists in the examples I have seen but I still
get a run-time error "type mismatch" and when I click
debug the line with the openrecordset is highlighted. I
have tried a couple of different ways of but still get an
error.

Method1: using the table name directly
Dim db as Database
Dim Actions as Recordset

Set db = CurrentDb

Set Actions = db.OpenRecordset("tblActions")

Method2: using SQL to open the table
Dim db as Database
Dim Actions as Recordset

Set db = CurrentDb

Set Actions = db.OpenRecordset("SELECT * FROM _
tblActions")


Neither of these methods is working, can anyone tell me
why I am getting a type-mismatch error and/or how I might
fix this problem

Thanks
 
P

Peter Russell

Kendrick previously wrote:

Method1: using the table name directly
Dim db as Database
Dim Actions as Recordset

Dim Actions as dao.recordset

Regards

Peter Russell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top