By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,425 Members | 2,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,425 IT Pros & Developers. It's quick & easy.

Table access via recordsets

P: n/a
This is driving me nuts -
I 'm trying to open a table programmatically, to add or modify records, and
I can't put all the pieces together to make it work in Access 2000. I have
all sorts of apps in 2.0 and 97 to self-plagiarize, but the syntax changes
with every release.
I've tried long enough to get it myself, that I'm ready to "depend on the
kindness of strangers..." Can anyone give me the magic few lines I need to
do this? That is, what workspaces/databases have to be DIM'd, opening the
RS, etc After this, I think I can get the RS.MoveNexts and Updates right.
Thanks one and all,
Armando
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
To Add:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Set Db = CurrentDb()
Set Rst = Db.OpenRecordset("MyTable")
Rst.Add
Rst!NameOfField1 = <Expression or Value>
Rst!NameOfField2 = <Expression or Value>
Rst!NameOfField3 = <Expression or Value>
....
....
Rst.Update
Rst.Close
Set Rst = Nothing
Set Db = Nothing

To Edit:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Set Db = CurrentDb()
Set Rst = Db.OpenRecordset("MyTable")
Rst.FindFirst <Look uo FindFirst method in Help file.
Rst.Edit
Rst!NameOfField1 = <Expression or Value>
Rst!NameOfField2 = <Expression or Value>
Rst!NameOfField3 = <Expression or Value>
....
....
Rst.Update
Rst.Close
Set Rst = Nothing
Set Db = Nothing
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com


"Armando" <ar*****@bogusaddress.com> wrote in message
news:HB*******************@news1.epix.net...
This is driving me nuts -
I 'm trying to open a table programmatically, to add or modify records, and I can't put all the pieces together to make it work in Access 2000. I have all sorts of apps in 2.0 and 97 to self-plagiarize, but the syntax changes
with every release.
I've tried long enough to get it myself, that I'm ready to "depend on the
kindness of strangers..." Can anyone give me the magic few lines I need to do this? That is, what workspaces/databases have to be DIM'd, opening the
RS, etc After this, I think I can get the RS.MoveNexts and Updates right.
Thanks one and all,
Armando

Nov 13 '05 #2

P: n/a
pks
Hi, Armando. One of the changes in A2K is that ADO is used by default
and DAO is not. Both of these have recordsets available, but they
work differently.

First, make sure you include DAO in your references. In the VBA
window, go to Tools | References, and then find "Microsoft DAO 3.6
Object Library". Click to select.

Then, you can either (a) make sure that DAO is listed before ADO, or
(b) specify a DAO recordset as opposed to a (generic default)
recordset.

For (a), make sure that the DAO is listed before "Microsoft ActiveX
Data Objects 2.1 Library" by using the Priority up/down buttons. That
will have a recordset by default be a DAO recordset rather than an ADO
recordset.

For (b), which would be good practice regardless, you would include in
your code:
Dim rsMyRecordset as DAO.Recordset

rather than
Dim rsMyRecordset as Recordset

I suppose ADO has its advantages, but to tell the truth I stuck with
what I knew when moving from 97 to 2K.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.