txt and field justification

pungentSapling

NeedHotSauce?
Local time
Today, 18:14
Joined
Apr 4, 2002
Messages
115
Wow, this .txt export is causing me a whole lotta grief....I mean Wow, what a great learning experience.

I am using a query to export to a text file.
the field I am having trouble with is a text field and it needs to be right justified.
The justification is correct for the query, and the dynaset comes out correct. Problem is when I run the export, the data shows up in the .txt file left justified.

How can I force the right justification to stay in place through the export process?

thanks again
p
 
If you are in AC2K you can build a format including the ! character. Look up help topic "User Defined String Formats" and play with that. The ! forces right-to-left fill rather than left-to-right fill.

It's a good thing you didn't ask for "centered" 'cause that would have been harder.
 
I am using Access 97 and the ! format only seems to force left justification on number fields...it does not seem to reverse default justification on text fields.
I have no problem getting right justification when viewing the data using access....it is after the data is exported to text that the justification gets reversed(returned to default "left").

thanks
 
pungent,

to get right justification to a text file, you will need to add spaces to the left of your field to get the desired length.


you could use the Lpad function (from NeatCode97) in your query.

----------
Function LPad(S, ByVal C As String, N As Integer) As String
'
' Adds character C to the left of S to make it right-justified
'
If Len(C) = 0 Then C = " "
If N < 1 Then
LPad = ""
Else
LPad = Right$(String$(N, left$(C, 1)) & S, N)
End If
End Function
----------

this expression in your query

Expr1: LPad([YourField]," ",10)

would add the proper number of spaces to the start of your field to right-justify it into 10 characters.

(note that this assumes you have no leading spaces...)

hth,
al
 

Users who are viewing this thread

Back
Top Bottom