PC Review Forums Newsgroups Microsoft Access Microsoft Access VBA Modules Accessing tables via VBA

Reply

Accessing tables via VBA

 
Thread Tools Rate Thread
Old 01-07-2003, 01:40 AM   #1
Dan Artuso
Guest
 
Posts: n/a
Default Re: Accessing tables via VBA


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.

--
HTH
Dan Artuso, Access MVP


"Kendrick" <mtelbert@amigo.net> wrote in message
news:03f801c33f61$5ef380e0$a501280a@phx.gbl...
> 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



  Reply With Quote
Old 01-07-2003, 01:43 AM   #2
Kendrick
Guest
 
Posts: n/a
Default Accessing tables via VBA

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
  Reply With Quote
Old 01-07-2003, 07:33 PM   #3
Kendrick
Guest
 
Posts: n/a
Default Re: Accessing tables via VBA


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

>-----Original Message-----
>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.
>
>--
>HTH
>Dan Artuso, Access MVP
>
>
>"Kendrick" <mtelbert@amigo.net> wrote in message
>news:03f801c33f61$5ef380e0$a501280a@phx.gbl...
>> 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

>
>
>.
>

  Reply With Quote
Old 01-07-2003, 08:12 PM   #4
Peter Russell
Guest
 
Posts: n/a
Default Re: Accessing tables via VBA

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
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off