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

Importing new entries only from .csv file

Hi There!

Currently I am importing a .csv file that eventually grows over
time. I have setup my table with an unique id field that is the
primary key and indexed. I have also indicated in the import
specifiaction that this field is indexed and that no duplicates
should be accepted.

My problem right now is that each time I import this file into
my database, it will overwrite what already exists and I would
have to go back and redo all my corrections.

Here is the script that runs when we click to download the
information:

Private Sub DownloadWaiver_Click()
On Error GoTo Err_DownloadWaiver_Click

Dim strFileName As String
Dim strPathExample As String
Dim strImportSpec As String
Dim strTableName As String
Dim strQueryName1 As String
Dim strQueryName2 As String

strPathExample = "Save File as i:\arfeedtobedone\waiver_data.csv"
strImportSpec = "Waiver Import Specification"
strTableName = "tblWaiver"

strFileName = "i:\arfeedtobedone\waiver_data.csv"
strQueryName1 = "01_updateqryWaiverSSN"
strQueryName2 = "02_updateqrytblWaiverSystemPIDM"
' Set warnings to off
DoCmd.SetWarnings False

' Import Health Waiver file
DoCmd.TransferText acImportDelim, strImportSpec, strTableName, strFileName,
False, ""

' Change the Health Waiver file info into a format to feed Banner
DoCmd.OpenQuery strQueryName1, acNormal, acEdit
DoCmd.OpenQuery strQueryName2, acNormal, acEdit

' Reset warnings to on
DoCmd.SetWarnings True

MsgBox "Health waivers have been added to tblWaiver."

Exit_DownloadWaiver_Click:
Exit Sub

Err_DownloadWaiver_Click:
MsgBox Error$
Resume Exit_DownloadWaiver_Click

End Sub

Is there anyway to modify this so that Access will not import
the entries that already exist?

Thanks for your help!

--
Regards,

George Yeh
Nov 13 '05 #1
3 2024
Why not link to the file instead of importing it. You can then use a query
to transfer the new records to your working table.
--
Terry Kreft
MVP Microsoft Access
"George Yeh" <ge**@lneohsipgahm.edu> wrote in message
news:cb**********@fidoii.CC.Lehigh.EDU...
Hi There!

Currently I am importing a .csv file that eventually grows over
time. I have setup my table with an unique id field that is the
primary key and indexed. I have also indicated in the import
specifiaction that this field is indexed and that no duplicates
should be accepted.

My problem right now is that each time I import this file into
my database, it will overwrite what already exists and I would
have to go back and redo all my corrections.

Here is the script that runs when we click to download the
information:

Private Sub DownloadWaiver_Click()
On Error GoTo Err_DownloadWaiver_Click

Dim strFileName As String
Dim strPathExample As String
Dim strImportSpec As String
Dim strTableName As String
Dim strQueryName1 As String
Dim strQueryName2 As String

strPathExample = "Save File as i:\arfeedtobedone\waiver_data.csv"
strImportSpec = "Waiver Import Specification"
strTableName = "tblWaiver"

strFileName = "i:\arfeedtobedone\waiver_data.csv"
strQueryName1 = "01_updateqryWaiverSSN"
strQueryName2 = "02_updateqrytblWaiverSystemPIDM"
' Set warnings to off
DoCmd.SetWarnings False

' Import Health Waiver file
DoCmd.TransferText acImportDelim, strImportSpec, strTableName, strFileName, False, ""

' Change the Health Waiver file info into a format to feed Banner
DoCmd.OpenQuery strQueryName1, acNormal, acEdit
DoCmd.OpenQuery strQueryName2, acNormal, acEdit

' Reset warnings to on
DoCmd.SetWarnings True

MsgBox "Health waivers have been added to tblWaiver."

Exit_DownloadWaiver_Click:
Exit Sub

Err_DownloadWaiver_Click:
MsgBox Error$
Resume Exit_DownloadWaiver_Click

End Sub

Is there anyway to modify this so that Access will not import
the entries that already exist?

Thanks for your help!

--
Regards,

George Yeh

Nov 13 '05 #2
Hi Terry!

Just had someone else suggest this also and I think it will work.

Thanks!!

George

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:R8********************@karoo.co.uk...
Why not link to the file instead of importing it. You can then use a query to transfer the new records to your working table.
--
Terry Kreft
MVP Microsoft Access
"George Yeh" <ge**@lneohsipgahm.edu> wrote in message
news:cb**********@fidoii.CC.Lehigh.EDU...
Hi There!

Currently I am importing a .csv file that eventually grows over
time. I have setup my table with an unique id field that is the
primary key and indexed. I have also indicated in the import
specifiaction that this field is indexed and that no duplicates
should be accepted.

My problem right now is that each time I import this file into
my database, it will overwrite what already exists and I would
have to go back and redo all my corrections.

Here is the script that runs when we click to download the
information:

Private Sub DownloadWaiver_Click()
On Error GoTo Err_DownloadWaiver_Click

Dim strFileName As String
Dim strPathExample As String
Dim strImportSpec As String
Dim strTableName As String
Dim strQueryName1 As String
Dim strQueryName2 As String

strPathExample = "Save File as i:\arfeedtobedone\waiver_data.csv"
strImportSpec = "Waiver Import Specification"
strTableName = "tblWaiver"

strFileName = "i:\arfeedtobedone\waiver_data.csv"
strQueryName1 = "01_updateqryWaiverSSN"
strQueryName2 = "02_updateqrytblWaiverSystemPIDM"
' Set warnings to off
DoCmd.SetWarnings False

' Import Health Waiver file
DoCmd.TransferText acImportDelim, strImportSpec, strTableName,

strFileName,
False, ""

' Change the Health Waiver file info into a format to feed Banner
DoCmd.OpenQuery strQueryName1, acNormal, acEdit
DoCmd.OpenQuery strQueryName2, acNormal, acEdit

' Reset warnings to on
DoCmd.SetWarnings True

MsgBox "Health waivers have been added to tblWaiver."

Exit_DownloadWaiver_Click:
Exit Sub

Err_DownloadWaiver_Click:
MsgBox Error$
Resume Exit_DownloadWaiver_Click

End Sub

Is there anyway to modify this so that Access will not import
the entries that already exist?

Thanks for your help!

--
Regards,

George Yeh


Nov 13 '05 #3
In message <cb**********@fidoii.CC.Lehigh.EDU>, George Yeh
<ge**@lneohsipgahm.edu> writes
Hi There!

Currently I am importing a .csv file that eventually grows over
time. I have setup my table with an unique id field that is the
primary key and indexed. I have also indicated in the import
specifiaction that this field is indexed and that no duplicates
should be accepted.

My problem right now is that each time I import this file into
my database, it will overwrite what already exists and I would
have to go back and redo all my corrections.


The problem looks to be a fundamental one in that you are using a
surrogate key in your table in place of any natural key in the data
itself. Theoretically the best solution is to abandon your existing
unique ID field and use a natural key from the data as your primary key.
If you do that duplicates will always be rejected, so only new entries
will be added.

I suggest that you reconsider your database structure to try to avoid
using a surrogate key if it isn't necessary.

The suggestion that has already been made, creating a linked table, will
only work if you have a suitable key in the data. This is because that
is the field (or combination of fields) that you will have to use to
join the existing table with the linked table. Since you need a key
anyway, consider using it as the primary key on your tables. There are
often good reasons why this impractical but it is always worth
considering.

--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #4

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

Similar topics

2
by: Vsevolod (Simon) Ilyushchenko | last post by:
Hi, Last year I have written a Perl module to serve as a backend to Macromedia Flash applications: http://www.simonf.com/amfperl I have just rewritten it in Python, which I have not used...
4
by: Howard | last post by:
I am trying to use DoCmd.TranferSpreadsheet to import a spreadsheet into an Access table that's not the CurrentDB. I have the database open, but I don't see how to tell the TransferSpreadsheet...
7
by: nizar.jouini | last post by:
Hello. I have long text file whitch is formatted like this: nextrow4 asdf asdf
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
3
by: Sam Alexander | last post by:
Hi Everone, I'm writing a script to import data from an XML file, and this tutorial is really an awesome guide : http://www.kbalertz.com/Q316005/Import.Server.Component.aspx ... problem though...
1
by: G Gerard | last post by:
Hello I am creating a wizard so a user can import data from other type of databases (DBase IV, Paradox etc...) into an Access mdb. The first step would require the user to choose the type and...
3
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file...
5
by: MLH | last post by:
I'm using A97 import data wizard to import text file N2 a table. The text file is a DIR listing produced by running dir jdc*.* /s c:\JDCs.txt The wizard is chopping the lines off at the...
0
by: Shootah | last post by:
Hi, I have succeeded in adding automated relationships with refference tables after importing an excel file created from a query to an Access database. However I have the following problem: ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.