Results 1 to 7 of 7
  1. #1
    Radtastic10 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    65

    File Export Code not working

    I am trying to export 3 different query results to text files. I was trying to use DoCmd.TransferText. However, it is saying that there is formatting file so it fails. I tried creating one, and thought it was going to work cause I could see it in Access, but when run it still failed. Not sure where to go from here.



    Code:
    Private Sub Data_File_Creation_Click()
     DoCmd.OpenQuery "QueryA", acViewNormal, acEdit
     
     DoCmd.TransferText acExportFixed, "ExQueryA", "QueryA", "File Path"
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    this works , i use it.

    Transfer text requires the SPEC file, (specification layout)
    yours says : ExQueryA
    docmd.TransferText acExportDelim ,spec,query,fileName,true

    did you creat ExQueryA spec with the correct formats?
    if not you must manually create it by importing text data, click ADVANCED in the import wizard (bottom left corner) then build and save your specname.
    Last edited by ranman256; 09-12-2017 at 04:50 AM.

  3. #3
    Radtastic10 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    65
    I thought I did, but I guess not. I will give this a try. Hopefully it will work. Cause I have seen a couple other ideas, but they are all a lot more complicated.

  4. #4
    Radtastic10 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    65
    Just to give you an update. I have tried to create spec file manually. Still isn't working. Don't know if I missed a step some where in the import process. I have also looked a little bit into just creating a fso. Would I still be able to get the results that I want or would that just make it a more complicated process?

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Still isn't working
    How is it not working?
    Are you getting an error message? If so, what exactly does it say.
    If you just aren't getting the expected behavior, please let us know exactly what is happening.

    Also, please post your actual code, so we can see exactly as you have written it (i.e. "File Path" is not a valid File Path).

  6. #6
    Radtastic10 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    65
    The error code is a runtime error that says it can not find the spec file/that is doesn't exist. The code is listed in the initial post. I don't see how me posting a file path would help. They are pretty self explanatory in their application.

    It is not working because it doesn't export the query results like it is supposed to. I am aware that the problem is the spec file interaction, just trying to find possible solutions.

  7. #7
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You need to follow the steps RanMan gave your for creating the Export Specification.
    Basically, you are working through it once, and saving your Export Specification details with any name that you choose.
    Then, use that exact saved Export Spec name in your VBA code. If it is saying it doesn't exist, then you are not entering the right name (the name you saved your Export Spec as).

    I don't see how me posting a file path would help
    I just want to make sure that you are, in fact, putting an actual File Path in that argument, and don't really have "File Path" in your code (as that obviously would not work!).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-03-2017, 09:25 PM
  2. Replies: 2
    Last Post: 10-15-2014, 02:23 AM
  3. Replies: 13
    Last Post: 12-12-2013, 07:22 PM
  4. Replies: 2
    Last Post: 08-05-2012, 06:32 PM
  5. VBA code for export to pdf file
    By Milan25 in forum Programming
    Replies: 4
    Last Post: 02-01-2011, 12:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums