I know you can do it individually with:
DoCmd.RunSQL "DROP INDEX [ColumnName] on TableName" with the only change being ColumnName
DoCmd.RunSQL "DROP INDEX * on TableName;" orDoCmd.RunSQL "DROP INDEX $ on TableName;" gets Runtime Error 3295
I know you can do it individually with:
DoCmd.RunSQL "DROP INDEX [ColumnName] on TableName" with the only change being ColumnName
DoCmd.RunSQL "DROP INDEX * on TableName;" orDoCmd.RunSQL "DROP INDEX $ on TableName;" gets Runtime Error 3295
design table, set field index to no, save.
I am importing an excel file via DoCmd.TransferSpreadsheet 0, 9, "Temp", strFile, 1
Then I am dropping many columns and some have indexes and will not delete. Thus I have to drop indexes withDoCmd.RunSQL "DROP INDEX [ColumnName] on TableName", there are 12 indexes, thus 12 lines of the same code with differing column names.
I am looking at the transferspreadsheet to not import indexes, or be able to remove all indexes at once. Dropping indexes and columns is not a necessary step, but would like to know.
As far as I'm aware transfer spreadsheet won't create an index.
It would only utilize one if the table being imported to already had one?
So modifying your table would only need doing the once, so not much need to do it with code?
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
I have the code made up to delete the indexes, but it adresses each individual one. I was trying to find a wildcard type way an minimize code.
Create a make table query from the existing one, no indexes would be created, then delete the original one and rename the new table.
I still can't really see the need to automate a one off process.
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
I don't think so (taken literally) but to try to answer that from the point of coding, I'd say only by looping each field in a table and testing if it has an index before attempting to delete it (as opposed to just attempting to delete and handling the resulting error). Then again, there's no substitute for minimizing code by not using it at all when not necessary.I was trying to find a wildcard type way
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.