• Help – Export query to multiple text files

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Help – Export query to multiple text files

    Author
    Topic
    #411788

    I have a query that I need to export/create multiple text files based on the grouping of one field in the query.

    For example I would need to create two texts from the following data (all info for ABC in one file and all info for CDE in another)

    ABC DESC1
    ABC DESC2
    CDE DESC1
    CDE DESC2

    Is there a quick way to do this?

    Viewing 0 reply threads
    Author
    Replies
    • #895265

      If you want to export a query to a text file for a particular grouping, just setup a parameter for the grouping required. When the query is run it will ask for the parameter and the resulting query result can be exported to a text file via the File/Export…

      • #895275

        There are hundreds of these so a parameter query isn’t the best solution in this case. I would like to have this process somehow completely automated without user intervention.

        • #895328

          I would setup a form that contains a text field that is used for the grouping field, lets call it txtGroupField.
          Behind a button I would code the following:
          Read each group (this could be a query that is opened as a recordset)
          Set Forms!Formname!txtGroupField with the name of the group that has been read from the recordset
          Use DoCmd.TransterText for the query you have that has a parameter based upon Forms!Formname!txtGroupField, the filename could have the grouping field as part of it’s name
          Loop

          I’m not too sure if you need to feed the parameter to the query in advance of the TransferText command.

          If you need any help in coding this, please post back.

        • #895329

          I would setup a form that contains a text field that is used for the grouping field, lets call it txtGroupField.
          Behind a button I would code the following:
          Read each group (this could be a query that is opened as a recordset)
          Set Forms!Formname!txtGroupField with the name of the group that has been read from the recordset
          Use DoCmd.TransterText for the query you have that has a parameter based upon Forms!Formname!txtGroupField, the filename could have the grouping field as part of it’s name
          Loop

          I’m not too sure if you need to feed the parameter to the query in advance of the TransferText command.

          If you need any help in coding this, please post back.

      • #895276

        There are hundreds of these so a parameter query isn’t the best solution in this case. I would like to have this process somehow completely automated without user intervention.

    Viewing 0 reply threads
    Reply To: Help – Export query to multiple text files

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: