Format Function

  • Thread starter Thread starter dkuntz
  • Start date Start date
D

dkuntz

Guest
I am having some trouble formatting some fields in a recordset.
<Example below>
The following results are displayed in a text file.

'Code
----------------------------------------------------------------------------------
Print #FileNO, "550000" & !FromName & Space(25) & !CallerName & Space(20) & !FromStreet1 & "~"
-----------------------------------------------------------------------------------

I would prefer to do without !FieldName & Space(#), rather I would prefer to do something like: Format(!FieldName, Space(#)).

For example using the code above if the contents of !FromName was only 9 characters then I would want 16 spaces before !CallerName. In the event !FromName is 28 characters long I would still only want to display 25. Make sense? How would I format this?

Any help or better suggestions are appreciated!
 
It sounds like you would have an easier time if you:
create a table with fields set to the lengths you want,
put values in the fields - align as you wish,
export the table to a fixed-width text file.

Forget the "Format" stuff.

RichM
 
I went with a Function to do this as shown below:

Print #FileNO, "550000" & SizedField(!FromName, 35) & SizedField(!CallerName, 35) & SizedField(!FromStreet1, 35) & SizedField(!FromZip, 9) & "~"


Private Function SizedField(ByRef sText As String, ByRef iLen As Integer) As String

SizedField = Left$(sText & Space$(iLen), iLen)

End Function


Thanks!
 

Users who are viewing this thread

Back
Top Bottom