473,382 Members | 1,409 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,382 software developers and data experts.

append query

hi

i have a general question regarding append queries in access 97. each
week i need to update my table(tblonlinereg) with new or modified
records. firstly, i import the text file into my database and then i
create a basic append query that appends the new records to the
table(tblonlinereg). this works great if the [tempID] field is
greater than the last record appended ( where: tempID > 198 ) but how
would i update/append the modifications for [datepaid] or [address]
for records that are less than 198. say if there is a change of
[address] for tempID 118? i have looked at the other discussions
strings on google and ms support site but i still cannot find how to
append new and updated records to my table(tblonlinereg).

any thoughts?
thanks in advance -jung
Nov 12 '05 #1
2 5758
Hi,

In order to update existing records, you need to sue a Update query instead
of an Append query

The generic SQL syntax for an update query is

Update tblonlinereg set yourfield = <your new value> where <some condition>

But with Update query, you cannot update at once a table (all or several
records) with values from several records from another table (for example to
update existing records from tblonlinereg with values from text file at
once)

Instead, you have to use VBA code to loop through all existing records, and
for each of them run the Update query

dim db as DAO.Database
dim rs DAO.Recordset

set db = Curentdb
set rs = db.openrecordset("select * from <your_temp_import_table> where
TempID in (select tempID from tblonlinereg)")
if rs.recordcount >0 then
do while not rs.eof
db.execute "Update tblonlinereg set yourfield1 = <the new value>,
yourfield2 = <the new value>, etc where tempID = " & rs!tempID)
rs.MoveNext
loop
endif

Hope this helps.
If you have any other questions, you can contact me back

Regards,
Bogdan

"JMCN" <pi******@yahoo.fr> wrote in message
news:27**************************@posting.google.c om...
hi

i have a general question regarding append queries in access 97. each
week i need to update my table(tblonlinereg) with new or modified
records. firstly, i import the text file into my database and then i
create a basic append query that appends the new records to the
table(tblonlinereg). this works great if the [tempID] field is
greater than the last record appended ( where: tempID > 198 ) but how
would i update/append the modifications for [datepaid] or [address]
for records that are less than 198. say if there is a change of
[address] for tempID 118? i have looked at the other discussions
strings on google and ms support site but i still cannot find how to
append new and updated records to my table(tblonlinereg).

any thoughts?
thanks in advance -jung

Nov 12 '05 #2
Hi Bogdan,
Thanks for the help! I started to work with the code but I was
wondering how one would identify the change of dates? for instance,
the [updated] will either be a different date or remains the same. how
would you write "is not equal to" condition? oh finally i forgot to
indicate that i'm using access 2002 version.

thanks again!! jung

for example:

Function UpdateRegistration()
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = Curentdb
Set rst = db.openrecordset("SELECT * FROM tblConvention WHERE
[updated] in (SELECT [updated] FROM tblonlinereg)")
If rs.RecordCount > 0 Then
Do While Not rst.EOF
'update the record (including all fields) if the
tblConvention![updated] field is not equal to tblonlinereg![updated]
db.Execute "UPDATE tblonlinereg SET updated <> updated", WHERE
updated <> " & rst!updated);
rst.MoveNext
Loop
End If
End Function

*************************************************

"Bogdan Zamfir" <bz*****@despammed.com> wrote in message news:<bs************@ID-218369.news.uni-berlin.de>...
Hi,

In order to update existing records, you need to sue a Update query instead
of an Append query

The generic SQL syntax for an update query is

Update tblonlinereg set yourfield = <your new value> where <some condition>

But with Update query, you cannot update at once a table (all or several
records) with values from several records from another table (for example to
update existing records from tblonlinereg with values from text file at
once)

Instead, you have to use VBA code to loop through all existing records, and
for each of them run the Update query

dim db as DAO.Database
dim rs DAO.Recordset

set db = Curentdb
set rs = db.openrecordset("select * from <your_temp_import_table> where
TempID in (select tempID from tblonlinereg)")
if rs.recordcount >0 then
do while not rs.eof
db.execute "Update tblonlinereg set yourfield1 = <the new value>,
yourfield2 = <the new value>, etc where tempID = " & rs!tempID)
rs.MoveNext
loop
endif

Hope this helps.
If you have any other questions, you can contact me back

Regards,
Bogdan

Nov 12 '05 #3

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

Similar topics

2
by: John | last post by:
Hi - I am trying to perform a simple append query, with no luck. I have a table (MktPrices) that has the following fields: BondID, PriceDate, Price. The objective is to allow the user to input a...
2
by: Danny | last post by:
I want to extract a subset of fields from one table into another the master table has many fields the subset has about half, but still many. Is there a way I can just append the master into the...
1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
3
by: Larry Rekow | last post by:
As part of a macro, I'm trying to automate appending a table with new records. let's say the table 2 has some new records in it, but also has a lot of identical records to table 1. I would...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
4
by: robboll | last post by:
When I try to use an append query from an oracle link it takes forever. I am exploring the idea of doing an append action using a pass-through query. If I have an Oracle ODBC connection to...
4
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the...
4
by: pmacdiddie | last post by:
I have an append query that needs to run every time a line item is added to a subform. The append writes to a table that is the source for a pull down box. Problem is that it takes 5 seconds to...
10
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
4
by: Scott12345 | last post by:
Hi, here is my situation, I have a DB that tracks machine downtime (30 machines) per day. Several users will update this through the day. I created an append query that creates 30 dummy values and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.