Results 1 to 3 of 3
  1. #1
    nggman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    27

    VBA script to transfer results of query to fixed width text file

    I have an Access query with many fields. I want to write a VBA script to transfer the results of the query to a fixed width text file. I do not need headers. I have all the specifications for the fields and their widths. I believe I need to start with the DoCmd.TransferText command and transferType:=acExportFixed but I am not positive. I just need a little push to get started. When I try just a simple transfer I get an error saying that I need a Specification Name argument.



    DoCmd.TransferText transferType:=acExportFixed, TableName:="Name of my query", FileName:="C:\temp\TEST.txt"

  2. #2
    dashiellx's Avatar
    dashiellx is offline Falconer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Baltimore
    Posts
    49
    Before you can do it in code, you'll need to do a manual export to create and save an Export Specification.

    Right click on your query and select Export-->Text File



    The "Save As" screen opens:

    Click OK and the "Export Text Wizard" opens:


    Click Advance and then set up everything you want:


    Save your Specification and then you can do it in code:

    DoCmd.TransferText acExportDelim, "Specification Name", "Query Name", strFileName

  3. #3
    nggman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    27
    Thanks for the quick response!!

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

Similar Threads

  1. Export Fixed Width file with Detail Section
    By DTaylor in forum Import/Export Data
    Replies: 5
    Last Post: 03-17-2016, 09:57 AM
  2. Replies: 2
    Last Post: 10-15-2014, 02:23 AM
  3. Replies: 5
    Last Post: 02-20-2011, 08:22 PM
  4. export query to fixed width text
    By eladz949 in forum Import/Export Data
    Replies: 1
    Last Post: 02-08-2011, 07:28 AM
  5. export query to fixed width text
    By eladz949 in forum Import/Export Data
    Replies: 5
    Last Post: 01-01-2011, 03:28 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