473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing 4 separate records from one line of an import file

Hi,
I've got an import procedure working, using a standard import
specification to import a .csv file into a temporary table.

The problem i'm having is that i have 4 different sets of borrower
details on the same line e.g. B1-Title, B1-Initials, B1-Surname,
B2-Title, B2-Initials, B2-Surname, etc.
all linked to my main borrower table via an unique account number.
My 1st append query matches which account numbers are new to the main
table and appends the 1st line no problem, however, as soon as the 1st
borrower details are added, the query can no longer find the difference
in account numbers, with them already now existing, so borrower's 2,3
and 4 details are lost.

Is there anyway i can append all 4 borrowers details so that each set
of borrowers details would append separately to the main borrower table
giving 4 separate records all linked with the same account number?

thanks in advance

Richard

Aug 29 '06 #1
11 2466
Looks like you could import to your temporary table and then append the
data with the account number to the child tables. It's hard to tell,
since your sample data has no account number, though. If you don't
have the account number in the imported data, you could probably import
the data, use an update query to write in the account number, and then
append those where the accountnumber is not null.

Aug 29 '06 #2

pi********@hotm ail.com wrote:
Looks like you could import to your temporary table and then append the
data with the account number to the child tables. It's hard to tell,
since your sample data has no account number, though. If you don't
have the account number in the imported data, you could probably import
the data, use an update query to write in the account number, and then
append those where the accountnumber is not null.
Thats what i'm doing. I'm using the account number on the main table
and the temp import table to determine which accounts aren't there
already, and then appending the 1st set of borrower details from my
temp table to the main table. the problem is, once i've imported the
1st set of borrowers details, the link between the temp table and the
main table is lost (due to the account number now being populated off
the 1st borrower append query) so i now have no way of importing the
2nd, 3rd and 4th set of borrowers details to the main borrower table.
Is that any clearer?

Thanks
Rich

Aug 29 '06 #3
Rich,

Oh, I think I get it now. You're basically using a find unmatched
query to get the data. One way around this might be to open a
recordset based on this query and then run a bunch of updates/appends
in code, so that the data doesn't disappear. Either that or flat out
read the primary key in code, save it to a variable, and then use it in
the addnew part of the code.

if that's not it, could you post the barebones structure of the two
tables you're importing into? Could be I'm missing something.

Aug 29 '06 #4
"kaisersose1995 " wrote
>Looks like you could import to your
temporary table and then append the
data with the account number to the
child tables. It's hard to tell, since your
sample data has no account number, though.
If you don't have the account number in
the imported data, you could probably import
the data, use an update query to write in the
account number, and then append those where
the accountnumber is not null.

Thats what i'm doing. I'm using the account
number on the main table and the temp import
table to determine which accounts aren't there
already, and then appending the 1st set of
borrower details from my temp table to the
main table. the problem is, once i've imported the
1st set of borrowers details, the link between
the temp table and the main table is lost (due
to the account number now being populated off
the 1st borrower append query) so i now have
no way of importing the 2nd, 3rd and 4th set
of borrowers details to the main borrower table.
Is that any clearer?
Perhaps we might be able to help if you would clarify the specific details
of your Tables, how the Borrowers relate to Accounts, and what part the
Title may play in this. It's entirely possible that it is a problem that
will have to be handled by some redesign... and without the details, your
description of the problem you face is not, in fact, clear (nor even
clearer). Not to me, at least.

Larry Linson
Microsoft Access MVP
Aug 29 '06 #5

pi********@hotm ail.com wrote:
Rich,

Oh, I think I get it now. You're basically using a find unmatched
query to get the data. One way around this might be to open a
recordset based on this query and then run a bunch of updates/appends
in code, so that the data doesn't disappear. Either that or flat out
read the primary key in code, save it to a variable, and then use it in
the addnew part of the code.

if that's not it, could you post the barebones structure of the two
tables you're importing into? Could be I'm missing something.
I'll give the recordset idea a blast, think that could be the answer,
thanks

Aug 29 '06 #6

Larry Linson wrote:
"kaisersose1995 " wrote
>Looks like you could import to your
>temporary table and then append the
>data with the account number to the
>child tables. It's hard to tell, since your
>sample data has no account number, though.
>If you don't have the account number in
>the imported data, you could probably import
>the data, use an update query to write in the
>account number, and then append those where
>the accountnumber is not null.
>
Thats what i'm doing. I'm using the account
number on the main table and the temp import
table to determine which accounts aren't there
already, and then appending the 1st set of
borrower details from my temp table to the
main table. the problem is, once i've imported the
1st set of borrowers details, the link between
the temp table and the main table is lost (due
to the account number now being populated off
the 1st borrower append query) so i now have
no way of importing the 2nd, 3rd and 4th set
of borrowers details to the main borrower table.
Is that any clearer?

Perhaps we might be able to help if you would clarify the specific details
of your Tables, how the Borrowers relate to Accounts, and what part the
Title may play in this. It's entirely possible that it is a problem that
will have to be handled by some redesign... and without the details, your
description of the problem you face is not, in fact, clear (nor even
clearer). Not to me, at least.

Larry Linson
Microsoft Access MVP
Larry,
I have a main table which lists account details including an account
number and a concatenated borrower name. I also have a borrower table
which lists the same account number and borrower details such as title,
initials, surname etc. The relationship between main table and
borrowers is 1 to many, i.e. upto 4 borrowers can have the same account
number (e.g husband and wife), but can only have one account on the
main table. I am trying to append data from a temporary table
(populated from importing a .csv file) to the borrower table. The
import file has all 4 borrowers details as well all all the other main
account information on one line. I am using a query linking the temp
table to the borrower table via account number to determine which
account numbers appear in the temp table and which do not. If the
account number is not already on the borrowers table, it appenda the
data to the table. The problem with this is that only 1st borrowers
details are being appended to the table, because after that, the
account number for the remaining borrowers now exists in both tables,
so the query cannot find any new accounts to append, and running an
update query would only update the one borrowers details thats already
stored, and not add the remaining 3 borrowers records to the borrowers
table.

if you still require basic structure how should i represent this? in
words, or is there the facility for diagrams?

thanks

Rich

Aug 29 '06 #7
Perhaps we might be able to help if you would clarify the specific details
of your Tables, how the Borrowers relate to Accounts, and what part the
Title may play in this. It's entirely possible that it is a problem that
will have to be handled by some redesign... and without the details, your
description of the problem you face is not, in fact, clear (nor even
clearer). Not to me, at least.

Larry Linson
Microsoft Access MVP

Larry,
I have a main table which lists account details including an account
number and a concatenated borrower name. I also have a borrower table
which lists the same account number and borrower details such as title,
initials, surname etc. The relationship between main table and
borrowers is 1 to many, i.e. upto 4 borrowers can have the same account
number (e.g husband and wife), but can only have one account on the
main table. I am trying to append data from a temporary table
(populated from importing a .csv file) to the borrower table. The
import file has all 4 borrowers details as well all all the other main
account information on one line. I am using a query linking the temp
table to the borrower table via account number to determine which
account numbers appear in the temp table and which do not. If the
account number is not already on the borrowers table, it appenda the
data to the table. The problem with this is that only 1st borrowers
details are being appended to the table, because after that, the
account number for the remaining borrowers now exists in both tables,
so the query cannot find any new accounts to append, and running an
update query would only update the one borrowers details thats already
stored, and not add the remaining 3 borrowers records to the borrowers
table.
Accounts(Accoun tNumber(PK), other info)
Borrowers(Accou ntNumber(FK), FirstName, LastName...)

or if you're into SQL

CREATE TABLE Accounts(
AccountNumber text(20) PRIMARY KEY,
CreateDate DATE,
....)

CREATE TABLE Borrowers(
BAccount text(20),
FirstName text(20),
LastName text(20),
PRIMARY KEY (BAccount, FirstName, LastName),
FOREIGN KEY (BAccount) REFERENCES Accounts(Accoun tNumber));

My guess is still to open a recordset based on Accounts, or whatever
that table is, and then loop through the 4 fields. Check for null. If
not null, append to Borrowers.

But Larry's definitely right. If you want a good answer, you really
need to give enough information for someone to accurately recreate the
key parts of the problem: table structures (with data types), maybe one
or two <maybe truncatedsample records if your example is not clear.
The key thing to keep in mind is that we have nothing but what you tell
us to go on. So it's up to you to provide the necessary details (and
_ONLY_ the necessary details). 2000 lines of code or whatever is WAY
too much.

Hope it helps a little

Aug 29 '06 #8
Now, back to my question... (1) are the records you described as your input,
the ones with Title, a record of a particular "borrowing, " or are they
intended to provide _new records_ for the Accounts and Borrowers Table. (2)
That is, can you rely that the record will include all the Borrowers
associated with the Account (my recollection is that you did say those
records, contrary to your original post, do include the Account number).
(3) Will they contain either new records (which you would Append) or may
they also contain maintenance updates (in which case, you might use an
Update Query to modify existing information).

Now, back to my previous question. (4) What is the relationship of Title in
those records? I'd have guessed, from that information being present, they
were a record of a particular "borrowing" and not new/updated Account and
Borrower information.

And other: (5) Could a given set of input contain more than one record for a
given Account? (6) If so, what determines which is the "authoritat ive
source" for the information... sequence in the input, a date field, or
??? -- that is, if there are two records for an Account, and the Borrower
information is different, which should be used?

As is obvious, the input data is un-normalized, which makes it more
difficult to handle, especially if it includes updates... not impossible,
but not as easy. Clearly, you have found that you can't use the absence of
an Account to determine whether you add a Borrower, if you establish the
account when you add the first Borrower.

You can use the absence of an Account to determine whether to establish a
new Account, but you'll have to handle Borrowers for that Account
separately.

We will not deal, now, with borrowers with the same First and Last name, for
example, a Father named John A. Smith and a Son named John Z. Smith... names
are notoriously unreliable keys in general, but may work in specific
situations.

Larry Linson
Microsoft Access MVP
"kaisersose1995 " <ka************ @hotmail.comwro te in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
>
Larry Linson wrote:
>"kaisersose199 5" wrote
> >Looks like you could import to your
temporary table and then append the
data with the account number to the
child tables. It's hard to tell, since your
sample data has no account number, though.
If you don't have the account number in
the imported data, you could probably import
the data, use an update query to write in the
account number, and then append those where
the accountnumber is not null.

Thats what i'm doing. I'm using the account
number on the main table and the temp import
table to determine which accounts aren't there
already, and then appending the 1st set of
borrower details from my temp table to the
main table. the problem is, once i've imported the
1st set of borrowers details, the link between
the temp table and the main table is lost (due
to the account number now being populated off
the 1st borrower append query) so i now have
no way of importing the 2nd, 3rd and 4th set
of borrowers details to the main borrower table.
Is that any clearer?

Perhaps we might be able to help if you would clarify the specific
details
of your Tables, how the Borrowers relate to Accounts, and what part the
Title may play in this. It's entirely possible that it is a problem that
will have to be handled by some redesign... and without the details, your
description of the problem you face is not, in fact, clear (nor even
clearer). Not to me, at least.

Larry Linson
Microsoft Access MVP

Larry,
I have a main table which lists account details including an account
number and a concatenated borrower name. I also have a borrower table
which lists the same account number and borrower details such as title,
initials, surname etc. The relationship between main table and
borrowers is 1 to many, i.e. upto 4 borrowers can have the same account
number (e.g husband and wife), but can only have one account on the
main table. I am trying to append data from a temporary table
(populated from importing a .csv file) to the borrower table. The
import file has all 4 borrowers details as well all all the other main
account information on one line. I am using a query linking the temp
table to the borrower table via account number to determine which
account numbers appear in the temp table and which do not. If the
account number is not already on the borrowers table, it appenda the
data to the table. The problem with this is that only 1st borrowers
details are being appended to the table, because after that, the
account number for the remaining borrowers now exists in both tables,
so the query cannot find any new accounts to append, and running an
update query would only update the one borrowers details thats already
stored, and not add the remaining 3 borrowers records to the borrowers
table.

if you still require basic structure how should i represent this? in
words, or is there the facility for diagrams?

thanks

Rich

Aug 29 '06 #9
Sorry gents, this is the 1st time i've asked for more technical help,
i'll bear in mind the level of detail you require for future posts.

my 3 tables are
TempImport(ACCN O, TITLE-CUS1, INITIALS-CUS1, SURNAME-CUS1, TITLE-CUS2,
INITIALS-CUS2, SURNAME-CUS2,TITLE-CUS3, INITIALS-CUS3,
SURNAME-CUS3,TITLE-CUS4, INITIALS-CUS4, SURNAME-CUS4, other info)
Borrowers(Accou nt Number(PK), Borrower ID(PK), Title, Initials,
Surname)
sample data:

temp import table:
00150T-00102, Mr, RA, Martin, Mrs, K, Martin, , , , , , ,
00650U-03003, Mr, C, Siddons, , , , , , , , , , , ,
00650F-02988, Mr, J, Daglish, Mrs, M, Hepplewhite, , , , , , ,

borrowers:
00150T-00102, 29/08/06 14:52:15, Mr, RA, Martin
00150T-00102, 29/08/06 14:52:16, Mrs, K, Martin
00650U-03003, 29/08/06 14:52:20, Mr, C, Siddons
00650F-02988, 29/08/06 14:52:22, Mr, J, Daglish
00650F-02988, 29/08/06 14:52:22, Mrs, M, Hepplewhite

Just to clarify again,
I'm trying to split out the borrowers details in the temp table, and
append each set of new borrowers details to a new record in borrowers
table.
currently i'm using a select query to check is the account number on
the temp table already exists in the borrowers table using the
following sql:

SELECT tbl_TempImportT able.ACCNO, tbl_TempImportT able.[TITLE-CUS1],
tbl_TempImportT able.[INITIALS-CUS1],
tbl_TempImportT able.[FORNAME-CUS1], tbl_TempImportT able.[SURNAME-CUS1],
tbl_TempImportT able.[DOB-CUS1], tbl_TempImportT able.[HOME-TEL-CUS1],
tbl_TempImportT able.[WORK-TEL-CUS1], [FORWARD-ADD-LINE1] & ", " &
[FORWARD-ADD-LINE2] & ", " & [FORWARD-ADD-LINE3] & ", " &
[FORWARD-ADD-LINE4] & ", " & [FORWARD-ADD-LINE5] & ", " &
[FORWARD-POSTCODE] AS [FORWARD ADDRESS]
FROM tbl_TempImportT able LEFT JOIN tblBorrowers ON
tbl_TempImportT able.ACCNO = tblBorrowers.[Account Number]
WHERE (((tblBorrowers .[Account Number]) Is Null));

then imbedding this whithin an append query shown below:

INSERT INTO tblBorrowers ( [Account Number], Title, Initials, Forename,
Surname, [Date of Birth], [Telephone Number 1], [Telephone Number 2],
[Forwarding Address] )
SELECT [qry_IMPORT_Upda tetblBorrowers1-B1].ACCNO,
[qry_IMPORT_Upda tetblBorrowers1-B1].[TITLE-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[INITIALS-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[FORNAME-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[SURNAME-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[DOB-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[HOME-TEL-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[WORK-TEL-CUS1],
[qry_IMPORT_Upda tetblBorrowers1-B1].[FORWARD ADDRESS]
FROM [qry_IMPORT_Upda tetblBorrowers1-B1];

I have 2 queries for each borrower, 4 select queries and 4 append
queries. All queries are identical, except the B# changes from 1
through 4 for each specific query.
problem is once i run the 1st query, the account number exists in both
tables, and therefore i can't append the 3 other borrower records.

is that any clearer now?

many thanks for your patience and help

Richard

Aug 30 '06 #10

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

Similar topics

11
2239
by: Jeff Wagner | last post by:
I am importing a file which contains a persons name (firstName, middleName, etc). If I define a function to do this, how can I use the variables outside of that function? Here is the code: import string def getName(): data = open("enterName.txt")
12
2408
by: qwweeeit | last post by:
The pythonic way of programming requires, as far as I know, to spread a big application in plenty of more manageable scripts, using import or from ... import to connect the various modules. In some cases there is a further complication: module importing through an indirect mechanism, like: exec "from " + xxx + " import *". A part the fact that I have not understood the "real" difference between import and from ... import (or also from......
1
4601
by: Thomas R. Hummel | last post by:
Hello, I am importing a file using BCP, with a format file. It is a fixed-width file, which I am importing into a table that has a column for each field in the file. The columns in my import table are all defined as CHAR. I use it as a staging area to check the data (are dates formatted correctly, etc.) before moving it from there. In one of my files I have six records that contain strange characters (ascii codes of 03 and 02 if I am...
11
3430
by: Grim Reaper | last post by:
I am importing a .csv file into Access that has 37 fields. My problem is that sometimes the last field only has data at the end of the column (it looks like when you import a file into Access, for the last field, it only checks the top few 'cells' to see if there is any data, if not, the field is not imported). How do I 'force' Access to import the field, regardless if there is data in the top of the field or not? For instance, I might...
1
3683
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am trying to avoid this extra step. can access read in this file directly into a table as append data? thank you very much for any pointers
2
3615
by: nutthatch | last post by:
I want to be able to import an Excel spreadsheet into Access 2K using the macro command Transferspreadsheet. However, the file I am importing (over which I have no control) contains some records that are "dirty" i.e. the field contents do not comply with the expected format (date/time) and they end up in a seperate table of import errors. (The records in "error" are actually empty fields.) This is a regular event and I do not want to...
5
3184
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All districts have used the same excel template and populated the same 32 data fields (columns). I created one large excel file from all 49 files which gives me a master table of 60,000 or so records. I have tried to import this master table into access...
12
6230
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the datagrid. Once I can get to that point I need some way to be able to add new data only to the new columns that were added. Here is some of my code: //Function For Importing Data From CSV File public DataSet ConnectCSV(string filetable)
5
5606
by: kyosohma | last post by:
Hi, I am trying to create a post logon script which does various tasks, like setup a printer based on location. While most of it works very fast, I have a second Python script that I run that scans the PC using WMI (among other things) and writes the following to a database: Name, Username, Machine, IP, Login Date,CPU,Memory. The problem I have is that since I import WMI, it takes a long time and we have users complaining about it. So...
0
10567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10310
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
10074
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...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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
6847
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
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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
2983
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.