Need to use TransferText maintaining db record order

Posted on 2007-08-06
Last Modified: 2013-11-27

In a VBA module, I am trying to use TransferText to export a table's records in fixed-length format using the order that the records appear in the table.  (The table is created by an update statement that inserts records in the order I need.)  However, when I use TransferText, the record order in the exported fixed width file does not appear as it does in the table.

I can force the order by creating a query by hand that specifies the order and then exporting the records, but I need it to work dynamically.

In short, is there a way to force the record order to when exporting to fixed-width using TransferText?  I suppose I could create a recordset and print out each record individually but calculating padding for a  fixed-width, 30 field record is going to get messy.
Question by:enrite
    LVL 10

    Accepted Solution

    Creatae the Query and save it.
    In your TransferText command, specify the Query, not the table name.

    Author Comment

    Hi aesmike,

    Gah, duh...I just realized that when responding about how to dynamically create that query.  Of course, the data will change but not the query....



    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now