Access not indexing imports - bug?

P

Philibin

Hello, I searched the archives and did not see this asnwered; here is my
problem.

Every Monday I import text (csv) files into Access databases using a macro.
I have the import specifications set to import everything in the format I
need it. I also have some of the fields indexed (duplicates ok).

The problem is that the fields do not index. When I look at the resulting
table in design mode they are unindexed. and I have to manually change it to
"Yes (Duplicates OK)".

The database itself was originally an access97 database that was converted
to 2002. The import specifications were set to index after we converted.

I have tried recreating the tables, and the import specs, and they still do
not index when imported. I have also tried importing the files using vb code.

If I manually import the files using the import specs it will index the
field, but that defeats the purpose of having a macro to import the files in
the first place.

Any suggestions would be welcome. Thanks in advance. :)

-Bill
 
B

Brian

I may not be fully understanding the problem here, but if you are recreating
the table with each import, this can be solved as follows:

Import once manually to a new table.
Index the fields.
Save the table.

For future imports, import into the existing table, since the indexes
already exist. For this to work, the headers on the import file must match
the field names. If they do not, or are absent, you can automatically create
them in Excel as follows:

Create an Excel worksheet having the column headings to match the field
names. In that Excel sheet, write an Auto_Open macro that opens the .csv
file, inserts the column headings, and saves it. You can call this sheet from
within Access VB code by using Shell to open Excel.

If you want to clear the contents of the table before the import, run a
delete query against it to flush the contents before running your import.

I usually just program all the above onto the Click event of a button on a
form.
 
P

Philibin

yeah, Thanks. I did end up having a macro that deletes the data from the
formatted tables, then imports into the blank tables. I was more or less
just curious as to why importing into a new table will not index... when you
can specify to index in the import specs.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top