Solved

Import File into Database With VBA (Indexes and Primary key needed)

Posted on 2001-08-29
7
315 Views
Last Modified: 2012-05-04
I have to import a CSV file into a NEW table.
WITH INDEXES ON THE 2 FIRST FIELDS + AUTONUMBER PRIMARY KEY

Structure:
"BBC PRDB","BBC APOLLO","BBC0011 - ZPRDB ORDERS","75","1000"," "," ","22/06/01","094637","000000","22/06/01","094644","0.13","BBC MEDAS","BBC APOLLO BILLING","FTP OTHER STOCKLEY","ECSD-MEDIS","N","22-JUN-2001 9:46:37","186","627","83","169","931108500","13","12"

If I do this with File, Get External Data, Import, and follow the complete wizard.
Everything is imported OK!

TABLE STUCTURE BECOMES THEN
ID        Autonumber Primary Key Indexed No Duplicates
Sender    Text 255 Indexed (Duplicates OK)
Receiver  Text 255 Indexed (Duplicates OK)
...

If I save this file specification (File - Get External Data, Import, Advanced, Create a Spec and Save AS) to be able to use the VBA language to import:
DoCmd.TransferText acImportDelim, "MS Billing Import Specification", _
    "IQ RAW DATA", txtIQBillingFilePath.Value, False
The data is imported OK, but there are NO indexes on sender and receiver.

TABLE STUCTURE BECOMES THEN
ID        Autonumber Primary Key Indexed No Duplicates
Sender    Text 255 Indexed No
Receiver  Text 255 Indexed No

In the import specification I HAVE INDICATED that I want indexes on those 2 fields, but there are none.

Access Version is 97 sr2

Anyone knows why this happens and can think of a solution?

Thanks T
0
Comment
Question by:thimerion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 200 total points
ID: 6437097
You could add the indexes "manually" by using:

currentdb.execute("CREATE INDEX .......;")

Just check the helpfile for the exact syntax.

Nic;o)
0
 
LVL 6

Expert Comment

by:xSinbad
ID: 6439223
For MS help (as nico said)

The next example creates an index consisting of the fields HomePhone and Extension in the Employees table:

CREATE INDEX NewIndex ON Employees (HomePhone, Extension);
0
 
LVL 1

Author Comment

by:thimerion
ID: 6445089
OK Thanks for your help!
I use now the code:
DoCmd.TransferText acImportDelim, "MS Billing Import Specification", _
    "MsRawData", txtMSBillingFilePath.Value, False
CurrentDb.Execute "CREATE INDEX MSRD_Sender_idx ON MsRawData (Sender);"
CurrentDb.Execute "CREATE INDEX MSRD_Receiver_idx ON MsRawData (Receiver);"
CurrentDb.Execute "CREATE INDEX MSRD_Customer_idx ON MsRawData (Customer);"
CurrentDb.Execute "CREATE INDEX MSRD_DateAndTime_idx ON MsRawData (DateAndTime);"

To get the desired result.

However I have my doubts on the performance of this solution, as it takes quite a while to create indexes on the existing data.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:thimerion
ID: 6445104
Thanks!
But if you can find a more performant (quicker) way to import a 20Mb text file and add indexes, I'd be happy to hear it.
0
 
LVL 54

Expert Comment

by:nico5038
ID: 6445114
The creation of an index always asks time, as Access will have to build a file having all key's in it.
It's only necessary to build indexes when the appication is also using them.
To detect this you'll need to check the execution plans of the queries.

Personally I always start without extra indexes and when performance is growing bad, I'll add them.

Nic;o)
0
 
LVL 1

Author Comment

by:thimerion
ID: 6445165
I am definately using those indexes;
I run about 40 queries on that table with those indexed fields in the WHERE clause.

I was just wondering:

What is the most performant solution?
1*/Create empty table WITH indexes,
then add the data.
2*/Add the data, then create indexes.

Why is the import specification not doing it's work correctly?
0
 
LVL 1

Author Comment

by:thimerion
ID: 6445304
I just tested it myself...

Insert the data first,
then create the indexes takes access 1'20''

Create a table with indexes,
then insert the data takes access 1'35''

Anyway thanks again Nico
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question