Export data to sequential file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jason2412
    New Member
    • Mar 2007
    • 6

    #16
    ADezii - Thanks for the code. Do I just copy this into a module? Just not sure how I use the code so that I can see the text file generated.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #17
      Originally posted by jason2412
      ADezii - Thanks for the code. Do I just copy this into a module? Just not sure how I use the code so that I can see the text file generated.
      Just Copy and Paste it wherever you want. It can be placed in the Click() Event of a Command Button. a Function Procedure, Sub-Routine Procedure, etc. Replace the comma after Field1 if you want a different Delimiter, replace the comma after Field2 if you want an End of Record indicator. Change the Path of Sequential.txt if you like, and simply Open it to view the Output. Any other questions, feel free to ask.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32666

        #18
        Originally posted by jason2412
        Yes, I can see how I confused the matter when I included an example with commas.

        For clarity:

        Field 1 - Retail
        Field 2 - Sat
        Field 1 - Direct
        Field 2 - Sun

        The required output for the above example would be:

        Retail#SatDire ct#Sun

        So a hash is added after field 1 and a carriage return () is added after field 2. All the data would run sequentially (left to right).

        The hash and carriage return symbol is needed because a script needs that format.

        Hopefully that clarifies things and a solution can be provided.

        Big Thanks
        Do you need a record separator of a Carriage Return specifically, or would a Carriage Return / Line Feed sequence (standard DOS/Windows line separator) do?
        If so, then a standard text export would do for you.
        If not, ADezii's code, with simple modifications to use the '#' & <CR> (vbCR constant in VBA) in place of the ','s would be the recommended approach.
        In truth, for the former, using ADezii's code with the VbCrLf constant instead, would also work perfectly well for you.

        Comment

        • jason2412
          New Member
          • Mar 2007
          • 6

          #19
          Pasted the code in the click event of a command button but got a file/path access error. When I go into debug it highlights the line 'Open "C:\Sequential. txt" For Output As #1'.

          I created a folder in my C: called sequential...wa s that the right thing to do?

          Not very good with visual basic etc so not sure why that last line of code is not working.

          Ps...cheers to all for the help, appreciated!

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #20
            Originally posted by jason2412
            Pasted the code in the click event of a command button but got a file/path access error. When I go into debug it highlights the line 'Open "C:\Sequential. txt" For Output As #1'.

            I created a folder in my C: called sequential...wa s that the right thing to do?

            Not very good with visual basic etc so not sure why that last line of code is not working.

            Ps...cheers to all for the help, appreciated!
            There may be restrictions on the System that involved writing to the Root Directory of Drive C: (C:\). You can create any Folder/Sub-Folder you like but just remember to modify your code, specifically:
            Open "C:\NewFolder\S ub-Folder\Sequenti al.txt" For Output As #1

            Comment

            Working...