Frothingslosh
Premier Pale Stale Ale
- Local time
- Today, 16:37
- Joined
- Oct 17, 2012
- Messages
- 3,276
Okay, I'm trying to help a co-worker resolve an error he's encountering, and failing miserably.
The idea here that the user enters a month/date value into a text field and hits a button, and the system imports a text file that matches the entered value into a specific table.
Here is the code in question (double single quotes are used for the path because the site will not allow me to enclose the path without turning it into a hyperlink):
This code invariably results in 'Run-time error '3001': Invalid argument.
Observations and notes:
The idea here that the user enters a month/date value into a text field and hits a button, and the system imports a text file that matches the entered value into a specific table.
Here is the code in question (double single quotes are used for the path because the site will not allow me to enclose the path without turning it into a hyperlink):
Code:
Private Sub cmdImportDispositions_Click()
Dim FilePath As String
FilePath = ''\\snt201\AAFA\'' & Me.txtMMYY.Value & "DISP.txt"
DoCmd.TransferText acImportDelim, "Check Disp Import Specification", "Dispositions", FilePath, True
End Sub
Observations and notes:
- The import specification 'Check Disp Import Specification' exists.
- The import specification works perfectly when run manually.
- There are no fields added to the import specification that do not exist in the source text file.
- The field names listed in the specification match the field names in the destination table perfectly.
- The table 'Dispositions' exists, and the name is spelled correctly.
- The source data has a header line. I have attempted:
- Header row indicated in both specification and VBA
- Header row indicated in spec but not VBA
- Header row indicated in VBA but not spec
- Header row not indicated in either VBA or spec
- The file path resolves correctly. A different error entirely is generated when there is no matching file.
- There are 5 other command buttons that do a text import.
- Four of them have been in the app since the start.
- One of them is another new text import. This one had the same error, but the 5th time I re-created the same spec, it started working. Just to test, I re-created the spec 6 more times, and got a working spec executable by VBA precisely once more. I DID NOTHING DIFFERENTLY.
- Each different file type being imported has a drastically different structure, so re-using a spec is not an option.
- I have already spent an hour going through Google search results for this error, including a half-dozen different threads on this forum. None have helped me resolve this.
Last edited: