ACH Data to a TXT file

  • Thread starter Mark C via AccessMonster.com
  • Start date
M

Mark C via AccessMonster.com

I am creating a NACHA file. I have the format and have created the lines I
need to export. The info is stored into an array and a few varriables. I
need to send this data to a txt file and store it.

I have 2 questions.

1) how do I create and drop data from the VB part of Access into the Text
file?
2) how can I format the TXT file so that I can have 94 characters per line in
Landscape?

TIA for any help.
 
J

John Nurick

Hi Mark,

I am creating a NACHA file. I have the format and have created the lines I
need to export. The info is stored into an array and a few varriables. I
need to send this data to a txt file and store it.

I have 2 questions.

1) how do I create and drop data from the VB part of Access into the Text
file?

Here's one way:

Dim strFileSpec As String
Dim blOverwrite As Boolean
Dim lngFN As Long
Dim strLine As String

...

lngFN = FreeFile()
If blOverwrite Then
Open strFileSpec For Output As #lngFN
Else
Open strFileSpec For Append As #lngFN
End If

'write a line to the file
strLine = "blah blah blah"
Print #lngFN, strline
'repeat as required

Tidy up
Close #lngFN
2) how can I format the TXT file so that I can have 94 characters per line in
Landscape?

You can use expressions like these to format the contents of a variable
as a string of a given length:

Format(X, "000000.00") 'Right-aligns numeric value X with 2
decimal places in a 9-column field
padded with 0s
Left(S & Space(20), 20)'Left-aligns string S in a 20-column
field padded with spaces

There's nothing in a text file to say whether it's portrait or
landscape: that's a decision for any software that may print it.
 
M

Mark C via AccessMonster.com

Thanks a ton for the help

John said:
Hi Mark,
I am creating a NACHA file. I have the format and have created the lines I
need to export. The info is stored into an array and a few varriables. I
[quoted text clipped - 4 lines]
1) how do I create and drop data from the VB part of Access into the Text
file?

Here's one way:

Dim strFileSpec As String
Dim blOverwrite As Boolean
Dim lngFN As Long
Dim strLine As String

...

lngFN = FreeFile()
If blOverwrite Then
Open strFileSpec For Output As #lngFN
Else
Open strFileSpec For Append As #lngFN
End If

'write a line to the file
strLine = "blah blah blah"
Print #lngFN, strline
'repeat as required

Tidy up
Close #lngFN
2) how can I format the TXT file so that I can have 94 characters per line in
Landscape?

You can use expressions like these to format the contents of a variable
as a string of a given length:

Format(X, "000000.00") 'Right-aligns numeric value X with 2
decimal places in a 9-column field
padded with 0s
Left(S & Space(20), 20)'Left-aligns string S in a 20-column
field padded with spaces

There's nothing in a text file to say whether it's portrait or
landscape: that's a decision for any software that may print it.

TIA for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top