473,786 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

recordset handling question

tdr
I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.
I can read an entire row/recordset from table 1 into a recordset
using the following
strSQL_in = "select * from table1" ( and i can refer to the columns
as
needed)

but how do i write the entire recordset to table 3 without declaring
each column name.

I have over 70 fields to compare and 100+ fields to write to table 3

i tried the following but it does not pass the error checking of the
compiler.
strSQL_out = "insert into table3" + rsd!

TIA

May 29 '07 #1
7 2282
On 29 May 2007 04:58:08 -0700, tdr <tr****@gmail.c omwrote:
>I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.
How are you insuring that the row in Table1 is being compared to the correct row in Table2?
>
I can read an entire row/recordset from table 1 into a recordset
using the following
strSQL_in = "select * from table1" ( and i can refer to the columns
as
needed)

but how do i write the entire recordset to table 3 without declaring
each column name.
You can use the SELECT INTO statement to build a new table:

SELECT * INTO Table3 FROM Table1

This will create Table3 from TAble1 ... note that Table3 cannot exist, or an error occurs. Select Into supports the use
of Joins and such, so you could build a query that returns only the unique records in Table1, or in Table2 ...

See here for info on Select Into:
http://www.w3schools.com/sql/sql_select_into.asp

>
I have over 70 fields to compare and 100+ fields to write to table 3

i tried the following but it does not pass the error checking of the
compiler.
strSQL_out = "insert into table3" + rsd!

TIA
Scott McDaniel
scott@takemeout _infotrakker.co m
www.infotrakker.com
May 29 '07 #2
On 29 May 2007 04:58:08 -0700, tdr <tr****@gmail.c omwrote:

This smells like a bad database design, and you're going to compound
it by creating table3. There is no need for table3, because the data
can be calculated in a query:
More than likely there also is no need for table2, and all the data
could be stored in one table, perhaps with an additional flag to
indicate what type of record it is. Bad database design leads to
complications, such as the ones you're now running into.

Chances are you will persist going down this path, so here are a few
hints:
To find records in one table that don't occur in another, don't use a
recordset but use SQL:
select * from table2
where PrimaryKeyField not in (select PrimaryKeyField from table1)
(you DO use primary keys, right?)

To create table3, read up on MakeTable query, and turn the above query
into a MakeTable query.

-Tom.

>I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.
I can read an entire row/recordset from table 1 into a recordset
using the following
strSQL_in = "select * from table1" ( and i can refer to the columns
as
needed)

but how do i write the entire recordset to table 3 without declaring
each column name.

I have over 70 fields to compare and 100+ fields to write to table 3

i tried the following but it does not pass the error checking of the
compiler.
strSQL_out = "insert into table3" + rsd!

TIA
May 29 '07 #3
tdr
i'm already using the select * from option,
I thought it if I already had the recordset I could just write that to
table 3.
Scott McDaniel wrote:
On 29 May 2007 04:58:08 -0700, tdr <tr****@gmail.c omwrote:
I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.

How are you insuring that the row in Table1 is being compared to the correct row in Table2?

I can read an entire row/recordset from table 1 into a recordset
using the following
strSQL_in = "select * from table1" ( and i can refer to the columns
as
needed)

but how do i write the entire recordset to table 3 without declaring
each column name.

You can use the SELECT INTO statement to build a new table:

SELECT * INTO Table3 FROM Table1

This will create Table3 from TAble1 ... note that Table3 cannot exist, or an error occurs. Select Into supports the use
of Joins and such, so you could build a query that returns only the unique records in Table1, or in Table2 ...

See here for info on Select Into:
http://www.w3schools.com/sql/sql_select_into.asp


I have over 70 fields to compare and 100+ fields to write to table 3

i tried the following but it does not pass the error checking of the
compiler.
strSQL_out = "insert into table3" + rsd!

TIA

Scott McDaniel
scott@takemeout _infotrakker.co m
www.infotrakker.com
May 29 '07 #4
tdr
here want I'm trying to do.
I get a text file every day. ( a full load 300,000 records)
I import this file into the database
I need to compare todays file to the file I got yesterday,
if any rows have changed I want to move those to another table to be
exported out to a new text file to be loaded into our master system.
( I need to format these before I export them)
so I think I need three tables
table 1 - today data
table 2 - yesterdays data
table 3 - changes from table 1. (once formated these will be exported)
Tom van Stiphout wrote:
On 29 May 2007 04:58:08 -0700, tdr <tr****@gmail.c omwrote:

This smells like a bad database design, and you're going to compound
it by creating table3. There is no need for table3, because the data
can be calculated in a query:
More than likely there also is no need for table2, and all the data
could be stored in one table, perhaps with an additional flag to
indicate what type of record it is. Bad database design leads to
complications, such as the ones you're now running into.

Chances are you will persist going down this path, so here are a few
hints:
To find records in one table that don't occur in another, don't use a
recordset but use SQL:
select * from table2
where PrimaryKeyField not in (select PrimaryKeyField from table1)
(you DO use primary keys, right?)

To create table3, read up on MakeTable query, and turn the above query
into a MakeTable query.

-Tom.

I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.
I can read an entire row/recordset from table 1 into a recordset
using the following
strSQL_in = "select * from table1" ( and i can refer to the columns
as
needed)

but how do i write the entire recordset to table 3 without declaring
each column name.

I have over 70 fields to compare and 100+ fields to write to table 3

i tried the following but it does not pass the error checking of the
compiler.
strSQL_out = "insert into table3" + rsd!

TIA
May 29 '07 #5
tdr
here want I'm trying to do.
I get a text file every day. ( a full load 300,000 records)
I import this file into the database
I need to compare todays file to the file I got yesterday,
if any rows have changed I want to move those to another table to be
exported out to a new text file to be loaded into our master system.
( I need to format these before I export them)
so I think I need three tables
table 1 - today data
table 2 - yesterdays data
table 3 - changes from table 1. (once formated these will be exported)
Tom van Stiphout wrote:
On 29 May 2007 04:58:08 -0700, tdr <tr****@gmail.c omwrote:

This smells like a bad database design, and you're going to compound
it by creating table3. There is no need for table3, because the data
can be calculated in a query:
More than likely there also is no need for table2, and all the data
could be stored in one table, perhaps with an additional flag to
indicate what type of record it is. Bad database design leads to
complications, such as the ones you're now running into.

Chances are you will persist going down this path, so here are a few
hints:
To find records in one table that don't occur in another, don't use a
recordset but use SQL:
select * from table2
where PrimaryKeyField not in (select PrimaryKeyField from table1)
(you DO use primary keys, right?)

To create table3, read up on MakeTable query, and turn the above query
into a MakeTable query.

-Tom.

I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.
I can read an entire row/recordset from table 1 into a recordset
using the following
strSQL_in = "select * from table1" ( and i can refer to the columns
as
needed)

but how do i write the entire recordset to table 3 without declaring
each column name.

I have over 70 fields to compare and 100+ fields to write to table 3

i tried the following but it does not pass the error checking of the
compiler.
strSQL_out = "insert into table3" + rsd!

TIA
May 29 '07 #6
"tdr" <tr****@gmail.c omwrote
I need to compare todays file to the file I got yesterday,
if any rows have changed I want to move those to another table to be
exported out to a new text file to be loaded into our master system.
( I need to format these before I export them)
That's certainly different from my understanding of your initial post:

"I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3."

Perhaps my misunderstandin g is due to the fact that I am unaware of an
Access object named "row/recordset". "Rows" I know; "recordsets " I know;
"row/recordset" I've never heard of until your post. (Q 1) Which is it: do
you want to move only the Records which differ; or do you want to move the
entire Table? (Q 2) If the latter, do you want to replace the Table or do
you want to Append the new Table (which likely will result in duplicate
keyed records).

I don't believe you answered the question, "How do you know you are
comparing the comparable rows in the tables?" SELECT * FROM SomeTable just
selects all the rows (aka records); it doesn't compare anything. (Q 3)
Please clarify how you are comparing.

You have your database in front of you; we have to rely on your description.
If someone asks you a question or asks for clarification, they may not be
able to continue to help you if you disregard their request. It's a matter
of our knowing what we need to know to be able to assist as opposed to your
deciding what we need to know to be able to assist.

Larry Linson
Microsoft Access MVP


May 29 '07 #7
tdr
sorry for the confusion, I left out the compare code because I did not
need help with that part of the code.
I did include the part I need help with (writing the recordset to
table 3),
strSQL_out = "insert into table3" + rsd!

as to row/recordset, i was not sure what other would know it as, so I
stated both row or recordset.

the rest of the posting is just parts of the code i'm using and really
does not need to be looked at, but included if it helps me get an
answer to writing the whole recordset to table 3.

Set rsd = db.OpenRecordse t("SELECT * " & _
" from todays_file ")

Set rs = db.OpenRecordse t("SELECT * " & _
" from yesterdays_file ")

rs.MoveFirst
rsd.MoveFirst
Do Until rsd.EOF And rs.EOF

If rs.EOF Then
VY_E3PARTIC = "F9999999999999 "
Else
VY_E3GROUP = rs!E3GROUP
VY_E3PARTIC = rs!E3PARTIC
VY_E3DEPNO = rs!E3DEPNO
VY_E3EFFDT = rs!E3EFFDT
VY_E3END = rs!E3END .............
If rsd.EOF Then
VP_E3PARTIC = "F9999999999999 "
Else
VP_E3GROUP = rsd!E3GROUP
VP_E3PARTIC = rsd!E3PARTIC
VP_E3DEPNO = rsd!E3DEPNO
VP_E3EFFDT = rsd!E3EFFDT
VP_E3END = rsd!E3END...... ...
myStatus = (VP_E3DEPNO <VY_E3DEPNO)
myStatus = myStatus Or (VP_E3LAST <VY_E3LAST) .........
If myStatus = True Then
strSQL_ins1 = "insert into changes_file ........
db.Execute strSQL_ins1
verr = Err.Description
strSQL_ins1 = Nothing

end if
......
myStatus = False
rs.MoveNext
rsd.MoveNext
......
loop

......


Larry Linson wrote:
"tdr" <tr****@gmail.c omwrote
I need to compare todays file to the file I got yesterday,
if any rows have changed I want to move those to another table to be
exported out to a new text file to be loaded into our master system.
( I need to format these before I export them)

That's certainly different from my understanding of your initial post:

"I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3."

Perhaps my misunderstandin g is due to the fact that I am unaware of an
Access object named "row/recordset". "Rows" I know; "recordsets " I know;
"row/recordset" I've never heard of until your post. (Q 1) Which is it: do
you want to move only the Records which differ; or do you want to move the
entire Table? (Q 2) If the latter, do you want to replace the Table or do
you want to Append the new Table (which likely will result in duplicate
keyed records).

I don't believe you answered the question, "How do you know you are
comparing the comparable rows in the tables?" SELECT * FROM SomeTable just
selects all the rows (aka records); it doesn't compare anything. (Q 3)
Please clarify how you are comparing.

You have your database in front of you; we have to rely on your description.
If someone asks you a question or asks for clarification, they may not be
able to continue to help you if you disregard their request. It's a matter
of our knowing what we need to know to be able to assist as opposed to your
deciding what we need to know to be able to assist.

Larry Linson
Microsoft Access MVP
May 29 '07 #8

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

Similar topics

4
3093
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use the recordset to loop thru the recordset, update values from the recordset and then update the database by passing parmeters to another stored procedure. I would like to use the recordset object but can it be used to pass a parameter to a stored...
5
29848
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As Long) As Boolean Dim rsAssignedUser As ADODB.Recordset Dim strSelectUser As String
4
5718
by: Gerry Abbott | last post by:
Hi all. I wish to call a recordset from a function. Ive tried the following approach, -------------------------------------------------------- Function PassRS() As Recordset Dim db As Database Dim rs As Recordset Dim myQdf As QueryDef
6
6555
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
3
6901
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records from rsSource into rsDest - if it finds a key violation then it deletes the current record from rsDest and adds the new record from rsSource. This works perfectly - but only for the first found duplicate record, it brings up the error
6
5055
by: Tom | last post by:
What is the code for a recordset in error handling code when the error may or may not occur before the recordset was created? I tried the code below but get the message: Compile Error Invalid Use Of Object and Nothing is highlighted when I click debug. If RstSurveySection <> Nothing Then RstSurveySection.Close Set RstSurveySection = Nothing
3
2009
by: Support | last post by:
Hello: I have a stored procedure that returns two record sets: the first recordset returns two columns that have to do with internal error handling processes the second recordset returns a recodset containing multiple records I would like to capture the second recordset into a datatable....... Dim cn As New SqlConnection cn.ConnectionString = GetConnectionString() Dim cmd As New SqlCommand("Sproc_GenericGetDocTypes", cn)
5
1545
by: GoalieGW | last post by:
The below code is not giving me the desired result. I am trying to compare the same field on two seperate records. One being the current record, the other being the day before. The code works to a degree, but the "lngcompare" keeps resulting in 0. I am not getting the field data from the recordset. Any thoughts? Private Sub BOILER_1_GAS_METER_BeforeUpdate(Cancel As Integer) Dim rs As Recordset Dim lngcompare As Long Dim strmsg As...
5
5889
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public function returns a long string. This works. 2. A query has a calculated field based on the custom function above. This works when the query is run directly.
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.