?
Solved

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

Posted on 2001-08-29
7
Medium Priority
?
322 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 600 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

752 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