access-vbaCreate Text Delimited File in Access Vba


Introduction

Some times you may need to create a delimited text file for various uses. The following example is one of many ways to help you do that. I have used a pipe ("|") for my delimiter, to change that just change the assignment of the Sep variable. In my example I dump the recordset to an array, this is by no means the defacto approach, its just my go to. This can easily be done using the recordset itself as well.

Remarks

This is worth pointing out:

 Wholeline = Wholeline & aRR(i, j) & Sep

Because recordsets dump to arrays transposed, you will have to read it to the text file backwards. This is actually kind of handy if youre working with dynamic arrays, as it is already transposed for you, so redim'ing the "row count" can be done before any heavy lifting.

Also worth nothing:

You can easily transpose youre array by dumping it into a new one line by line using this syntax:

    Dim xaRR() As String
    ReDim xaRR(q, z)
    xaRR(j, i) = aRR(i, j)

this isnt too relevant to my post, but its worth pointing out.