質問

I am having some trouble exporting out to a file from VBA. Some things to be aware of are that JobDetail is a valid export SpecName and 2_JobDetail is a query that combines some info with stuff from other fields and tables. When I try to run I get the error like below on my DoCmd.TransferText method call. Advice? am I doing something wrong? code below.

enter image description here

Public Function exportJobDetailRecs(dateStr As String)
    'Docmd.TransferText(acexport,specName,TableName, FileName,HasfieldNames,HTMLTableName)   
    DoCmd.TransferText acExport, _
                        "JobDetail", _
                        "2_JobDetail", _
                        "P:\Folder1\Folder2\Tracker\" + CStr(dateStr + "_OrderStatus_jobdets.txt")   
    exportJobDetailRecs = CStr(dateStr + "_OrderStatus_jobdets.txt")
End Function

Some questions people have asked:

  1. Yes - Do you have full permission to write to the file (i.e. full permission to the folder as well as the text file if you are not creating it with code)
  2. Yes - Check path (folder name with space/etc) for mistakes.
    • and I'm copying with Shift-Right click, then copy as Path, and adding a trailing \ manually
  3. Yes - Have you try exporting manually and overwriting your existing spec and see if that works? If so, try runs the code again afterward
  4. Yes - Have you confirmed JobDetail is an export spec instead of an import spec?
    • and manual exports work fine
  5. 3-50 - How many records does 2_JobDetail currently return?
  6. Same - Try the export (temporarily) to "P:\Folder1\Folder2\Tracker\a.txt"
    • It doesn't care what folder (that exists) I point it to, it wont go
  7. None - Also make sure that there are no punctuation marks in strDate
役に立ちましたか?

解決

I figured this out. It wanted me to create the destination files too, not just the directories before I could copy to it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top