473,404 Members | 2,114 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,404 software developers and data experts.

"triaging" records from external DB to either update or insert into local access DB

Hello,

I thought I would do a "sanity check" by asking the experts how to do the following:

I need to process external data (it will be in an Access DB table and will be updated daily) into a local Access DB table that has the same structure with additional fields. The local table is prexisting and the designer used an autonumber field as its key. There is a "real key" between the two tables (let's call it PK1 for this discussion (it's not the autonumber field)). The external DB table is not keyed. My main question is: if I want to insert new records (those not having a corresponding field PK1 in the local table), and update existing records (the ones with the PK1 field in common), should I set up two recordsets and a case statement to send the new records to insert and the matching records to update? I'm an Access/VBA newbie who sometimes tends to get too complicated for my own good.

I saw an answer to an earlier post: http://www.thescripts.com/forum/thread558797.html

by Mary McCarthy that was interesting. Should I try something like that?

Thanks!!

Barbara
Dec 19 '06 #1
7 1853
Hi again,

Did I make this post hard to understand? I'm a little sleep deprived so please let me know if I should rewrite this so that it makes more sense ;-) and it's clearer what I'm asking.

Thanks.
Dec 19 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
First question Barbara

Why are you using a local table. Wouldn't linking to the table in the original database solve your problem.

Mary
Dec 20 '06 #3
First question Barbara

Why are you using a local table. Wouldn't linking to the table in the original database solve your problem.

Mary
Hi Mary,

The external Access database will be a file that comes from another group, is cumulative, and refreshed daily with new records added and/or changed. I need to import the data and insert new records into our version of the database, and update existing records. There are extra fields in our local Access DB so it isn't an exact copy but it will have all the fields in the external Access DB. I don't think that's a problem.

What I want to do is set up a form that an end user can use that will let them see only the new records (new meaning whatever they haven't processed yet either this day or previous days). Processed in this case means that they will click a radio button that says "Accepted" or "rejected" based on whether the record pertains to their group or not. Behind the scenes, all the records could go into our local database but I would give them a filtered view of those that they have accepted (in another form that would include all accepted records for the history of the application). The reason I wouldn't mind having all the records I could explain but it would take another page so I will leave that for another time...

The main thing I'm asking is: how can I set up some VBA to process the records to either update existing records or insert new ones? Should I use case statements? Should I use recordsets?

I *think* I might be able to do the other things I have mentioned but am having a hard time with the update/insert VBA since I'm a newbie.

Thanks and sorry this is so long!

Barbara
Dec 20 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
Hi Barbara

The question is too broad to answer. The method used will depend on where and from what the inserts and updates will be completed. The easiest method is by form but without a lot more information I can't tell.

Maybe I'm still misunderstanding the question.

Mary
Dec 20 '06 #5
Hi Barbara

The question is too broad to answer. The method used will depend on where and from what the inserts and updates will be completed. The easiest method is by form but without a lot more information I can't tell.

Maybe I'm still misunderstanding the question.

Mary
Maybe I should ask one thing at a time instead of building such an elaborate scenario. How about for the first step I ask: Is there a way to "compare" two tables to see which records are new?
Thanks for hanging in with my long-winded questions.
Dec 20 '06 #6
NeoPa
32,556 Expert Mod 16PB
Maybe I should ask one thing at a time instead of building such an elaborate scenario. How about for the first step I ask: Is there a way to "compare" two tables to see which records are new?
Thanks for hanging in with my long-winded questions.
I think your first post is along the right lines Barbara.
In Access, it is not even critical to separate the records first.
If you run an update query, (INNER JOIN) linking your two tables via your PK1, then only the correct records will be selected (and updated).
After that you can run an append query (INSERT INTO).
You can, if you prefer, restrict this query to just those records you don't already have, but this is not absolutely necessary as any duplicate records will be dropped anyway (assuming you have set PK1 to a Unique Index in your table).
Dec 21 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
Maybe I should ask one thing at a time instead of building such an elaborate scenario. How about for the first step I ask: Is there a way to "compare" two tables to see which records are new?
Thanks for hanging in with my long-winded questions.
Assuming Table1 has the new records and both tables have a primary key called ID ...

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM Table1 LEFT JOIN Table2
  2. ON Table1.ID = Table2.ID
  3. WHERE Table2.ID Is Null;
  4.  
This will return all records from Table1 that don't exist in Table2.

Mary
Dec 21 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
2
by: Jenny | last post by:
Hi! I wonder how to use conditions in the inserted table(in a insert/update) trigger? The inserted table contain all the rows that have been updated or inserted (for an update/insert trigger),...
1
by: Lisa | last post by:
I have an asp.net website with an Access Database that works great on my local server, but when I migrated to our production server, none of my sql processes works (i.e update, insert, delete) Does...
2
by: Gary | last post by:
If you develop a stand alone c# windows application that only reads from a single local Access database, do you need to close the connection each time you navigate to a different record? No other...
6
by: Peter Neumaier | last post by:
Hi, I am trying to select some data through a stored procedure and would like to store the result in a local access table. Is that possible? Can somebody provide an example? Thanks&regards!...
3
by: fourEyes | last post by:
Hi, I am really new at Access but have been reading and trying to learn. I hope someone can help me figure out how to either update or insert records from one DB table to another database table. ...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
2
by: Luting | last post by:
Hi, Is it possible to update oracle via Access forms? I am thinking maybe I could make a link table connnected with oracle database. And the form could be based on the link table. Does this...
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: 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...
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...
0
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...

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.