DoCmd.TransferText runtime error (1 Viewer)

tingler0

New member
Local time
Today, 17:38
Joined
Oct 25, 2007
Messages
7
i am trying to import a CSV file into a table based on the selected date but i am getting a run-time error '2495' The action or method requires a Table Name argument. Here is my code if anyone can help.

DoCmd.TransferText , acImportDelim, Contracts, "\\Zbnawlfs002\Dept\AR-Collections\CashApplications\ContractLogReport\(SelectDate).csv", True
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:38
Joined
Sep 12, 2006
Messages
15,634
when you enter the code, the autoprompts should offer you choices etc. Without checking, I think you may be missing parameter(s)

if contracts is the name of the new table, it should be enclosed in quote marks, otherwise access looks for a variable called contracts. This may be the error
 

boblarson

Smeghead
Local time
Today, 15:38
Joined
Jan 12, 2001
Messages
32,059
DoCmd.TransferText , acImportDelim, Contracts, "\\Zbnawlfs002\Dept\AR-Collections\CashApplications\ContractLogReport\(Se lectDate).csv", True
Well, first of all, there is no comma after TransferText and before acImportDelim.

Second, as gemma mentions Contracts would then be the import specification and it would need to be in quotes. The next field is the table name, not the path. So, I think you'd better check the TransferText properties again:
Microsoft Access VBA Help File said:
expression.TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)

But the help file doesn't mention not using the parentheses. So it should be:

Code:
expression.TransferText TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage
 

tingler0

New member
Local time
Today, 17:38
Joined
Oct 25, 2007
Messages
7
Well, first of all, there is no comma after TransferText and before acImportDelim.

Second, as gemma mentions Contracts would then be the import specification and it would need to be in quotes. The next field is the table name, not the path. So, I think you'd better check the TransferText properties again:


But the help file doesn't mention not using the parentheses. So it should be:

Code:
expression.TransferText TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage


Thank-you but now i am getting a Run-time error '31519' You cannot import this file.
 

boblarson

Smeghead
Local time
Today, 15:38
Joined
Jan 12, 2001
Messages
32,059
What's your actual code now that you've fixed it? Maybe it is still slightly askew.
 

tingler0

New member
Local time
Today, 17:38
Joined
Oct 25, 2007
Messages
7
After play with it a little yesterday i now have a runtime error '3044' not a valid path. i have verified the location of the file and it is correct, could be that it is on a server and not my C: drive?

here is the code.
DoCmd.TransferText , acImportDelim, "Contracts", "\\Zbnawlfs002\Dept\AR-Collections\CashApplications\ContractLogReport\" & (selectdate) & ".csv", True
 

boblarson

Smeghead
Local time
Today, 15:38
Joined
Jan 12, 2001
Messages
32,059
After play with it a little yesterday i now have a runtime error '3044' not a valid path. i have verified the location of the file and it is correct, could be that it is on a server and not my C: drive?

here is the code.
DoCmd.TransferText , acImportDelim, "Contracts", "\\Zbnawlfs002\Dept\AR-Collections\CashApplications\ContractLogReport\" & (selectdate) & ".csv", True

What is (selectdate) and how do you set it. That is probably the problem. First of all, you don't need the parentheses around selectdate and if you are trying to have someone enter it in as a parameter, use a form.
 

Users who are viewing this thread

Top Bottom