473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Table access via recordsets

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
2 1369
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jimserac | last post by:
I had previously posted this in an Access forum with negative results so will try here. Although this question specifies an Access database, I also wish to accomplish this with a large MS SQL...
11
by: deko | last post by:
I need to create different recordsets based on queries that use data from unbound fields in a form. I've discovered that I can't do this, and instead need to save the data in question (usually a...
8
by: Roy Padgett | last post by:
I have a combo box where users select the customer name and can either go to the customer's info or open a list of the customer's orders. The RowSource for the combo box was a simple pass-through...
5
by: Fabrice | last post by:
Hello everybody, I'm working with Access 2002. I have to import Data from a Foxpro table that contains 25000 records in an Access table. I have a couple of restrictions placed on me for the...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
5
by: AFN | last post by:
Hi. I'm pretty comfortable binding a single recordset result to a datagrid. But now I have a more unique problem. I have 2 really long stored procedures that cannot be combined at the SQL...
5
by: paulc05 | last post by:
Hi, I have a DB on a remote share that I want to update to a local DB periodically. My plan is to create a VBA procedure and then trigger the procedure a few times a day to the process is...
4
by: sphinney | last post by:
As my Access 2002 form opens, I want to find the names of the tables in the current Access database and populate a combobox with them. Problem is, the CurrentDb.Recordsets object is empty even...
1
by: ray2heavy | last post by:
Hey guys, I am getting a "database cant lock table "blah" because it is already in use by another person or process" while trying to delete, then re-populate it. This table is viewed in a subform...
11
by: BeckR | last post by:
Hello - Thanks for reading my post. I am a newbie when it comes to VBA programming, but have managed to do what I need to do, until now. I have an Access 2000 database (running WinXP Pro...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.