tags:

views:

45

answers:

2
DoCmd.TransferText acImportDelim, Import-Accounts, "tableImport", _
    "C:\Documents and Settings\accounts.txt", True

The second parameter: Import-Accounts is the actual name of the saved import specifications. supposedly it does NOT need to be in quotes; however in this case since there is a - there it is treating it as if i were doing an operation.

is there a way i can force it to treat it literally instead of as an operation?

+1  A: 

An obvious question would be: can you rename the saved spec? If not, can you put square brackets around it []? (This is what Access does for field names with spaces or that are reserved names) If not can you put quotes around it?

Jeremy
It is odd that this is the accepted answer, import specification is a string. Access itself suggests <filename> Import Specification as the name when choosing Advanced on the import form. This is true of all version from 2000 on, and possibly before.
Remou
This answer is wrong. The import spec name needs to have quotes for the string value to be passed. Otherwise, VBA will think the name of the import spec is an object or variable.
David-W-Fenton
@Remou: it is true of all versions I have ever used, starting with Access 2.
David-W-Fenton
+1 for fenton cause he's the man!
I__
+4  A: 

According to Access' help topic for TransferText, the SpecificationName option is "A string expression that's the name of an import or export specification you've created and saved in the current database". So I think you do have to enclose it in quotes, same as you did for TableName, which is also a string expression.

HansUp
hansup actually i have never put quotes on it and it did work in the past, the problem is actually wtih the dash
I__
@I__ I find that very strange. In any version of Access that I have used, import specification is a string, as stated by @HansUp, and is enclosed in quotation marks.
Remou
If you were passing a variable NAME, no you wouldn't use quotes. But if you're passing a string value, you need the quotes. You seem to be making this way more complicated than it is.
David-W-Fenton
+1 for fenton cause he's the man!
I__