EXPORT TO TEXT FILES WITH FIXED WITH POSITION

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HI,
Appreciate if someone could help me on the following problem. I have a
button to
export a table to text file with fixed width format.

1) How to write the code to export the field at the correct position ?
2) Some of the fields are numeric data types. By default the said fields in
the
exported file will be aligned to the left. I want it to be aligned to
the right.
Eg. Table 1
Data Type Start Size/Width
field1 Text 1 3
field2 Text 4 9
field3 Numeric 13 16
Eg.
By Default :
xxxyyyyyyyyy123.45
xxxyyyyyyyyy12345.67
xxxyyyyyyyyy1234567.89
I want it to be aligned to the right as below:-
xxxyyyyyyyyy 123.45
xxxyyyyyyyyy 12345.67
xxxyyyyyyyyy 234567.89

TQ so much.
 
You can try something in your query like:
Column3: Right(Space(20) & Format([field3],"#.00"),16)
 
I wish i could write it in codes behind the button but I'm not that good
enough. Glad
if someone could show me how. Anyway Tq.



Duane Hookom said:
You can try something in your query like:
Column3: Right(Space(20) & Format([field3],"#.00"),16)

--
Duane Hookom
MS Access MVP


GW said:
HI,
Appreciate if someone could help me on the following problem. I have a
button to
export a table to text file with fixed width format.

1) How to write the code to export the field at the correct position ?
2) Some of the fields are numeric data types. By default the said fields
in
the
exported file will be aligned to the left. I want it to be aligned to
the right.
Eg. Table 1
Data Type Start Size/Width
field1 Text 1 3
field2 Text 4 9
field3 Numeric 13 16
Eg.
By Default :
xxxyyyyyyyyy123.45
xxxyyyyyyyyy12345.67
xxxyyyyyyyyy1234567.89
I want it to be aligned to the right as below:-
xxxyyyyyyyyy 123.45
xxxyyyyyyyyy 12345.67
xxxyyyyyyyyy 234567.89

TQ so much.
 
You create your query and then step through the wizard to create a fixed
length text export. Then add code to a command button like:
Private Sub cmdExport_Click()
DoCmd.TransferText acExportFixed, "MySavedSpec", _
"qselQueryToExport", "C:\DeleteMe.txt"
End Sub


--
Duane Hookom
MS Access MVP


GW said:
I wish i could write it in codes behind the button but I'm not that good
enough. Glad
if someone could show me how. Anyway Tq.



Duane Hookom said:
You can try something in your query like:
Column3: Right(Space(20) & Format([field3],"#.00"),16)

--
Duane Hookom
MS Access MVP


GW said:
HI,
Appreciate if someone could help me on the following problem. I have a
button to
export a table to text file with fixed width format.

1) How to write the code to export the field at the correct position ?
2) Some of the fields are numeric data types. By default the said
fields
in
the
exported file will be aligned to the left. I want it to be aligned
to
the right.
Eg. Table 1
Data Type Start Size/Width
field1 Text 1 3
field2 Text 4 9
field3 Numeric 13 16
Eg.
By Default :
xxxyyyyyyyyy123.45
xxxyyyyyyyyy12345.67
xxxyyyyyyyyy1234567.89
I want it to be aligned to the right as below:-
xxxyyyyyyyyy 123.45
xxxyyyyyyyyy 12345.67
xxxyyyyyyyyy 234567.89

TQ so much.
 
Back
Top