Printing with formatted lines

M

Maracay

Hi Guys,
At work there is a very old production printing machine, the machine use a
DBASE data base program, the file is a .LST, the process to generate this
file is very manual, I created a program in access to speed up the generation
of this file, everything works but the final .LST file, I checked one of the
old file, and each line is formatted to 60 characters even when there are
more than 1 field printed in the line. When my file runs in the machine the
information is all over the place, the old file shows every line into a 60
charactersformat.
Sorry if it sounds confusing, if someone knows how to solve this problem or
have any question please let me know.
This is part of my code:

FileHandle = FreeFile()
Open strFileName For Output As FileHandle
On Error GoTo Err_handler
Dim rs As Recordset
Set rs = Recordset

rs.MoveFirst

Do Until rs.EOF
Print #FileHandle, Nz(Fname), Nz(LName)
Print #FileHandle, Nz(addreSS)
Print #FileHandle, Space(10)
Print #FileHandle, Trim(Nz(City, "")) & " " & Trim(Nz(Province, ""))
& " " & Trim(Nz(PostalCode))
Print #FileHandle, Space(10)
rs.MoveNext
Loop

Close #FileHandle

sExit:
Set rst = Nothing
Me.Requery
Exit Sub

Err_handler:
MsgBox Err.Description
Resume sExit
Close #FileHandle

End If

Thanks
 
M

Marshall Barton

Maracay said:
At work there is a very old production printing machine, the machine use a
DBASE data base program, the file is a .LST, the process to generate this
file is very manual, I created a program in access to speed up the generation
of this file, everything works but the final .LST file, I checked one of the
old file, and each line is formatted to 60 characters even when there are
more than 1 field printed in the line. When my file runs in the machine the
information is all over the place, the old file shows every line into a 60
charactersformat.
Sorry if it sounds confusing, if someone knows how to solve this problem or
have any question please let me know.
This is part of my code:

FileHandle = FreeFile()
Open strFileName For Output As FileHandle
On Error GoTo Err_handler
Dim rs As Recordset
Set rs = Recordset

rs.MoveFirst

Do Until rs.EOF
Print #FileHandle, Nz(Fname), Nz(LName)
Print #FileHandle, Nz(addreSS)
Print #FileHandle, Space(10)
Print #FileHandle, Trim(Nz(City, "")) & " " & Trim(Nz(Province, ""))
& " " & Trim(Nz(PostalCode))
Print #FileHandle, Space(10)
rs.MoveNext
Loop

Close #FileHandle
[snip]

Your code is generating a "line" in the file for each Print
statement. Is that what you want? Or do you want it all in
one "line"?

I suggest that you use a string variable to hold each output
"line" so you can add the required spaces to fillit out to
60 characters. Not that Print add a CR and LF to the end of
each "line". If you do not want that, add a semicolon at
the end of each Print statement. I also think you do not
want to use a comma between Nz(Fname) and Nz(LName),
probably should concatenate them with a single space.

Depending on what a "line" is, you might want something
like:

strLine = Left(Mid((" " + Fname) & (" " + LName), 2) _
& Space(60), 60)
Print #FileHandle, strLine ' maybe with a ; ???
 

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