473,473 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to extract from Dropped Records using InsertQuery

2 New Member
Hello I havent been able to put this question into the right words so I will be using an example.

I have 2 tables: "MasterList","RawData".

MasterList has a field 'ProjectID' with unique identifiers (say about 100) for various projects.

RawData uses ProjectID as a foreign key so any record inserted into RawData must have a key that exists in ProjectID.MasterList or the record will drop.

Now I am using a VBA/Queries to import a formated .csv file into my RawData table. My .csv starts with 1000 records but I wind up importing 900. The missing queries are due to ProjectIDs that do not exist in the "MasterList".

My Question(Finally): Is there a way to somehow grab the records that are automatically being dropped by access? I would then print these values out for the user to know so the new ProjectIDs may be added to the "MasterList"

My current solution would be to just use a Distinct SELECT Query on the .csv data (imported to a temp table) and compare the ProjectIDs.csv with the ProjectIDS.Masterfile before starting the import; however, I was wondering if there was a more creative solution to this anyone can share?

Note: My knowledge of SQL says no but I am suprised every day with the stuff people come up with.
Jul 14 '10 #1
3 1359
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Hi InsaneMembrane and welcome to Bytes.

Yes there is, its actually rather simple.

Ill go through the process:
1. Make a query containing both tables.
2. Join the tables by ProjectID in the query.
3. Double-Click the link/join between the tables, select the option: Include ALL posts from tbl_RawData and only those from tbl_Master where the joined fields are equal.
4. Finally: Add a criteria "Is Null" on the ProjectID field from the master table.
5. Select those fields you wish to include/show from the tbl_RawData.

In simple terms: The query selects all records from tbl_RawData, that does not have a matching ID in the master table. I've included a screenshot showing an example of such a query.



Depending on your needs, you could modify the query to automatically insert the missing IDs (depending a bit on your table setup).
Attached Images
File Type: jpg BytesQueryExample.jpg (20.8 KB, 247 views)
Jul 14 '10 #2
NeoPa
32,556 Recognized Expert Moderator MVP
First, before you do anything else, you need to change the import so that it imports into a table with no restrictions. This is essentially introducing an extra step into the procedure, but it does give you extra flexibility on down the line.

Next, you can import any valid data from this new table into your RawData table.

As you now have all the original data available to you inside your database, you can now produce a query/report of what failed and why. Smiley's post gives clear instructions on that aspect.

Welcome to Bytes!
Jul 14 '10 #3
InsaneMembrane
2 New Member
Thank you for both responses

NeoPa: Actually I did import the csv into a temp table since I needed to do some parsing and such since the data doesnt come in with correct formating (nor will it change grrr) so work was already done there :).

TheSmileyOne: lol I always ignore the Left/right join in access because I learned OracleSQL and somehow confused Joins with UNIONS lol. Everything works except I had it print the ProjectIDs that did not exist rather than the Project name because if the Project doesnt exist in the master list then nothing would be printed if we tried to print the name :p.

I threw in a Distinct in the SQL and got exactly what I needed.

This really is an easier method than what i was thinking. Thanks :).
Jul 14 '10 #4

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

Similar topics

40
by: Elijah Bailey | last post by:
I want to sort a set of records using STL's sort() function, but dont see an easy way to do it. I have a char *data; which has size mn bytes where m is size of the record and n is the...
1
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass...
0
by: Oberon | last post by:
How do I navigate through records using drag 'n' drop controls? I have an example in C# for Windows forms that relies on BindingContext but this is not available for ASP.NET. How do I solve that...
1
by: Hennie | last post by:
Hi Is it possible to insert records using the Footer row in a Gridview? I can do it with a datagrid in VS2003, but the same code in VS2005 give me an error: The code is: Dim strOperatorID As...
1
by: jmarr02s | last post by:
Is it possible to limit the number of Subform records using MS Access 2003? That is, my end users want the capability of entering up to 12 records on their subform. Is that possible? ...
0
by: pmaers | last post by:
I need a source code in Visual Basic .Net regarding about updating data records using MS Access database (.MDB).
3
by: tushar jadhav | last post by:
Suppose, i hv an 10 columns and next to that other columns in a DB Table. That 10 columns hv same default values & others are retriving from other table and are nearly 1000 records. How can i insert...
0
by: sathyan8294 | last post by:
i am using dotnet 2003.i want to move records using firstbutton,previous button,next button,last button in vb.net windows application(not web application).
1
by: sushant2009 | last post by:
Hi , I want to display empty databae table(actually table contains lot of records) to datagrid using dataset and dataadpter. After displaying i will fill new records in datagrid and i will save...
13
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. ...
0
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,...
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...
1
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
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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...

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.