473,399 Members | 4,192 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,399 software developers and data experts.

Adding data to a recordset

While adding data to a record set, I use something like

rst![Plot1] = some variable
rst![Plot2] = some variable
......
rst![Plot99] = some variable
The rst![Plot1] , rst![Plot2] etc. are manually typed in and it gets
tedious typing a lot of these.

If there some way to use a loop to setup the field names? Something like

For x = 1 to 99

rst![Plotx] = some variable(x)

next x
May 6 '06 #1
14 2338
You need someting like
For x = 1 to 99
rst("Plot" & x) = some variable(x)
next x

Arno R
"Karl Irvin" <88********@comcast.net> schreef in bericht news:qN******************************@comcast.com. ..
While adding data to a record set, I use something like

rst![Plot1] = some variable
rst![Plot2] = some variable
.....
rst![Plot99] = some variable


The rst![Plot1] , rst![Plot2] etc. are manually typed in and it gets
tedious typing a lot of these.

If there some way to use a loop to setup the field names? Something like

For x = 1 to 99

rst![Plotx] = some variable(x)

next x

May 6 '06 #2
Most clever developers would not use a recordset for updating data.

If they had to they would use a modern version of Access and ADO as in

Recordset.Update aFields, aValues

where aFields is a variant array of field names or ordinals and aValues
is a variant array of, surprise, values.

eg Air Code

Dim aFields(20) as Variant
Dim aValues as Variant
Dim Iterator as Long

For z = 0 to 19
aFields(z) = z
Next z

rst.Update aFields, Array(12, "John", 20.66 ... etc )

Unfortunately the norm for CDMA is the archaic and clumsy DAO.

May 6 '06 #3
"Lyle Fairfield" <ly***********@aim.com> wrote in
news:11**********************@e56g2000cwe.googlegr oups.com:
Most clever developers would not use a recordset for updating
data.
Now you are starting to sound like our good friend Steve.
If they had to they would use a modern version of Access and
ADO as in

Recordset.Update aFields, aValues

where aFields is a variant array of field names or ordinals
and aValues is a variant array of, surprise, values.

eg Air Code

Dim aFields(20) as Variant
Dim aValues as Variant
Dim Iterator as Long

For z = 0 to 19
aFields(z) = z
Next z

rst.Update aFields, Array(12, "John", 20.66 ... etc )
you can do something very similar in DAO, like
for z =0 to 19
rst.fields(z) = myArray(z)
next z
Unfortunately the norm for CDMA is the archaic and clumsy DAO.

It's not clumsy at all. You are just a Grumpy Old Man.

--
Bob Quintal

PA is y I've altered my email address.
May 6 '06 #4
Bob Quintal <rq******@sympatico.ca> wrote in news:Xns97BBB65FB2F5DBQuintal@
207.35.177.135:
For z = 0 to 19
aFields(z) = z
Next z

rst.Update aFields, Array(12, "John", 20.66 ... etc )


you can do something very similar in DAO, like
for z =0 to 19
rst.fields(z) = myArray(z)
next z


That's a lot similar ... UH HUH!

--
Lyle Fairfield
May 6 '06 #5
DFS
Lyle Fairfield wrote:
Most clever developers would not use a recordset for updating data.
A clever developer like me would gladly and repeatedly use the most modern
version of Access and a DAO recordset for adding or updating data if it
provides an advantage over an INSERT or UPDATE.

What advantage, you say? The only one that really matters: because I want
to.
If they had to they would use a modern version of Access and ADO as in

Recordset.Update aFields, aValues

where aFields is a variant array of field names or ordinals and
aValues is a variant array of, surprise, values.

eg Air Code

Dim aFields(20) as Variant
Dim aValues as Variant
Dim Iterator as Long

For z = 0 to 19
aFields(z) = z
Next z

rst.Update aFields, Array(12, "John", 20.66 ... etc ) Unfortunately the norm for CDMA is the archaic and clumsy DAO.


Versus the less-archaic but still clumsy ADO.

May 7 '06 #6
Absolutely! I'm sure you're happy that Microsoft Insiders revealed
today that MS will soon announce that a new DB connection technology
has superseded ADO.Net. According to unnamed sources it originates from
a need for vast amounts of memory and, as a result is modeled after
Star Trek Deep Space Nine. The connection components themselves will be
known as ODO; MS will offer certification in ODO entitling graduates to
use the moniker ODD after their names.
When asked about the inevitable question, "Why?" Bill Gates
wrinkled his nose and explained that the existence of ADO.Net no longer
seemed to justify DAO proponents in not learning or using ADO. "We
need to look to the future", he said, his gaze drifting off the sky
beyond his window. "We've hooked the Ferengi who use DAO for
another five years this way, because now they can explain their
peculiar clinging to this archaic, obsolete, and thoroughly ugly
technology by pointing out how pointless it would be to learn either
ADO or ADO.Net when both will be replaced soon."

May 7 '06 #7
So, if I understand, you are saying that Bill Gates is out to
Microshaft us again?

Q

'"Lyle Fairfield" <ly***********@aim.com> wrote in
news:11**********************@e56g2000cwe.googlegr oups.com:
Absolutely! I'm sure you're happy that Microsoft Insiders
revealed today that MS will soon announce that a new DB
connection technology has superseded ADO.Net. According to
unnamed sources it originates from a need for vast amounts of
memory and, as a result is modeled after Star Trek Deep Space
Nine. The connection components themselves will be known as
ODO; MS will offer certification in ODO entitling graduates to
use the moniker ODD after their names.
When asked about the inevitable question, "Why?" Bill Gates
wrinkled his nose and explained that the existence of ADO.Net
no longer seemed to justify DAO proponents in not learning or
using ADO. "We need to look to the future", he said, his gaze
drifting off the sky beyond his window. "We've hooked the
Ferengi who use DAO for another five years this way, because
now they can explain their peculiar clinging to this archaic,
obsolete, and thoroughly ugly technology by pointing out how
pointless it would be to learn either ADO or ADO.Net when both
will be replaced soon."


--
Bob Quintal

PA is y I've altered my email address.
May 7 '06 #8
It's a continuum! Only way we can get out is through a worm hole. Where
is Captain Jainway when we need her? (Maybe you need Seven of Nine
more?)

May 7 '06 #9
"Lyle Fairfield" <ly***********@aim.com> wrote
That's a lot similar ... UH HUH!


"Grump, grump, grump," he said, trying to figure out how he can claim that
classic ADO and ADO.NET share more than the letters "ADO" in their name. :-)
May 8 '06 #10
Having learned and used both, why would he care?
ADO.Net has its place. So has ADO. These places are specified in
current MS documentation.
DAO has its place too, in the background work of Access (and probably
other MS technologies that interact with databases.)
But in scripting/coding technology, except for a very few isoated
instances, DAO is clumsy and archaic. The process of DAO recordset
manipulation which we see questioned and answered in CDMA daily is
naive. The correct answer to almost all DAO recordset questions is,
"Don't."

May 8 '06 #11
"Lyle Fairfield" <ly***********@aim.com> wrote
But in scripting/coding technology, except
for a very few isoated instances, DAO is
clumsy and archaic.
Care to give a few examples of "clumsy and archaic" versus "not so clumsy
and archaic"? Start from the premise that most of us here are not of the
"newer is better" school of thought, so "newer" isn't going to be a
convincing argument for us.
The process of DAO recordset manipulation
which we see questioned and answered in
CDMA daily is naive. The correct answer to
almost all DAO recordset questions is,
"Don't."


"Naive" isn't something I associate with a technology, but with a person's
dealing with the world around them. I am convinced that I have correctly
answered many, many DAO questions over the years, and I can't remember a
single time that my answer was "Don't." Perhaps you could clarify what you
mean by the process being "naive".

As the native language of Jet, Microsoft says that DAO is faster. (Though I
rarely access data via DAO, or ADO, for _speed_, but only because the
circumstances dictate using code.) And, if I remember correctly, VBA/DAO is
more complete than ADOX for Jet.

Larry

May 10 '06 #12
Larry Linson wrote:
Care to give a few examples of "clumsy and archaic" versus "not so clumsy
and archaic
The most obvious is the requirement to release in code pointers to DAO
recordsets and databases as in
SET rcs = Nothing
SET db = Nothing
This anomaly of DAO, which can only be classified as a fundamental
failure, has caused tens of thousands of Access errors and accounted
for millions of lines of extraneous and redundant code.
We could go on from there to many areas; one is the inconvenience of
Updates which require Edit directives, then the reassignment of Field
values, and then Update directives. We could name the lack of
disconnected recordsets had not I originated and posted a solution for
this problem (using Transactions) many years ago.
"Naive" isn't something I associate with a technology, but with a person's
dealing with the world around them. I am convinced that I have correctly
answered many, many DAO questions over the years, and I can't remember a
single time that my answer was "Don't." Perhaps you could clarify what you
mean by the process being "naive".
In my opinion it marks a responder and his/her response as naive,
(inexperienced, raw or unsophisticated) when the manipulation of a DAO
Recordset is recommended as a solution. Almost always an SQL solution
is to be preferred. As I have pointed out in the once in a million
times where the use of a Recordset may be justified an ADO Recordset is
likely to be more facile than a DAO Recordset.
As the native language of Jet, Microsoft says that DAO is faster. (Though I
rarely access data via DAO, or ADO, for _speed_, but only because the
circumstances dictate using code.) And, if I remember correctly, VBA/DAO is
more complete than ADOX for Jet.


I agree that DAO has a minimal speed advantage over ADO. I believe that
this difference is so small that it will not be noticeable in almost
all cases.

As I have never championed or discussed ADOX to any extent I do not
understand why you would introduce that topic. I do not know of any
problem in JET/Access that can be solved with ADOX that cannot be
solved with ADO and the JET 4.0 SQL. If someone does I should be happy
to hear it.

I have, of course, contributed many DAO solutions to this newsgroup
over many years. Some of them presented or championed new, original
uses for its objects and methods. I am not denigrating a technology
which I do not know I am pointing out that a new and better technology
exists. The failure of many of the regulars here to progress past DAO
3.5/JET 3.5 puzzles me. Is it an innate conservatism? Is it because
they are so successful with DAO that they have no time to learn
anything new? Is it because they are successful, satisfied and fat with
DAO and do not want to learn anything new? Is it because they are
intolerant of the dissonance that might be caused by using two similar
technologies?

I will not be posting further to this thread.

May 10 '06 #13
"Lyle Fairfield" <ly***********@aim.com> wrote
Care to give a few examples of "clumsy and
archaic" versus "not so clumsy and archaic
The most obvious is the requirement to
release in code pointers to DAO
recordsets and databases as in
SET rcs = Nothing
SET db = Nothing
This anomaly of DAO, which can only be
classified as a fundamental failure, has caused
tens of thousands of Access errors and accounted
for millions of lines of extraneous and redundant code.


IIUC, what you describe is a "bug" that Microsoft has either been unable to
find and fix, or chose not to fix. I've not found it to be a problem to
include it in those instances where the circumstances dictated using DAO.
We could go on from there to many areas;
one is the inconvenience of Updates which
require Edit directives, then the reassignment
of Field values, and then Update directives.
Once you know what is required, this isn't a problem. I suppose it is a
problem, if you choose for it to be, though.
We could name the lack of disconnected
recordsets had not I originated and posted a
solution for this problem (using Transactions)
many years ago.
Well, if I ever find myself needing to use disconnected recordsets (seems to
be a function of doing more data access in code than I prefer to do), I'll
remember and Google your solution. In any case, once you solved it, didn't
it cease to be a problem.
"Naive" isn't something I associate with
a technology, but with a person's dealing
with the world around them. I am convinced
that I have correctly answered many, many
DAO questions over the years, and I can't
remember a single time that my answer was
"Don't." Perhaps you could clarify what you
mean by the process being "naive".


In my opinion it marks a responder and his/her
response as naive, (inexperienced, raw or unsophis-
ticated) when the manipulation of a DAO
Recordset is recommended as a solution. Almost
always an SQL solution is to be preferred.


I don't recall responding with "Don't" but I have often suggested an SQL or
Query solution -- most often, however, that SQL or Query had to be executed
some way, and that way was with DAO.
As I have pointed out in the once in a million times
where the use of a Recordset may be justified an
ADO Recordset is likely to be more facile than
a DAO Recordset.
I translate this to mean "You like it better."
As I have never championed or discussed ADOX to any extent I do not
understand why you would introduce that topic. I do not know of any
problem in JET/Access that can be solved with ADOX that cannot be
solved with ADO and the JET 4.0 SQL. If someone does I should be happy
to hear it.
I bring it up because it is part of ADO, for creating data objects, and is
less full-featured than the similar DAO functions.
... The failure of many of the regulars here to progress
past DAO 3.5/JET 3.5 puzzles me. Is it an innate conser-
vatism? Is it because they are so successful with DAO
that they have no time to learn anything new? Is it because
they are successful, satisfied and fat with DAO and do
not want to learn anything new? Is it because they are
intolerant of the dissonance that might be caused by
using two similar technologies?
If those developers have not progressed beyond 3.5, then they must also have
not progressed beyond Access 97. While there are many who think that Access
97 was a good release, perhaps the best-ever release, I think most of the
regulars here have moved on over time and now use later versions, which, per
se, means they are not using DAO 3.5 nor Jet 3.5.

My initial evaluation of ADO (which was hyped as better because of its
"simpler object model") was that all the same information was required to
accomplish a given I/O operation, but was just arranged in different
statements. I haven't changed that view, but I didn't have any objection to
the object model of DAO. About the time ADO came out, my work changed so
that instead of most of it being Access clients to servers, most was
Access - Jet (and the largest client-server system on which I worked since
was an ADP that used ADO -- far more than was needful, because the original
author had not realized that it was necessary to define a primary key on SQL
Server tables to use bound forms). The ADO in that application did not
change my opinion that investing time and effort in learning it would
benefit my MDBs.

Clearly, you have a preference for ADO and I have a preference for DAO.
Both, used appropriately, can satisfy application needs, so this is an area
where we can agree to disagree, civilly and politely, I think.
I will not be posting further to this thread.


Thanks for giving me the last word. Thanks also for the many correct, even
elegant solutions you have posted here in many areas.

Larry Linson
Microsoft Access MVP
May 10 '06 #14
"Lyle Fairfield" <ly***********@aim.com> wrote in
news:11**********************@u72g2000cwu.googlegr oups.com:
It's a continuum! Only way we can get out is through a worm
hole. Where is Captain Jainway when we need her? (Maybe you
need Seven of Nine more?)

I have a need for her twin sister, Two of Thirty-Eight,Double-Dee.

--
Bob Quintal

PA is y I've altered my email address.
May 10 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Z | last post by:
Some guidance por favor I started this program with the Data Form Wizard (never again). I'm pretty deep into it now, this piece of code keeps overwriting the first record in the DB: Private Sub...
1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
2
by: Robin S. | last post by:
This is an "Add product" form. The user will enter a ProductNo (catalog number), select a Product Class (from cascading combo boxes) and then click a button to create the product. When a...
1
by: Will | last post by:
Hi, I have a form which calculates a final cost (frmWorkCosts, data stored in tblWorkCosts) and once calculated adds this final cost (Which isn't saved in tblWorkCosts) into a different table...
2
by: super_dave_42 | last post by:
I am searching for a way to create multiple records in Access 2000 from a worksheet created in Excel. I'm pretty much self-taught with Visual Basic so forgive me if this poorly described. Basically...
5
by: joe donnelly | last post by:
I have a couple of questions about recordsets: 1. When a recordset is summoned by the code where does it actually exist and in what form...is it created in the database (data source location)...
1
damonreid
by: damonreid | last post by:
Access 2003 Microsoft Windows XP Pro Hey, I am currently pulling my hair out here. I have a Form for adding new projects to a database, the only problem is that when I close the form it doesn't...
4
by: jaz215 | last post by:
hi! how do i add a record in a database without using the datacontrol and adodc. i want to rework my code to using purely codes and not being dependent on the design on vb. so far i have. Set rs...
18
omerbutt
by: omerbutt | last post by:
AJAX PROB WITH MULTIPLE RECORDS helo iam having problem in ma code will any body look out an help, i am trying t add sale record in the database and the checkthe quantity of the part slod and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.