Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query results with text in certain position

Status
Not open for further replies.

asanchez4

Programmer
Apr 22, 2004
32
0
0
US
I have a requirement to create an export/report that outputs the fields in certain positions. For instance,

Name -- position 1 - 5
Zip Code -- position 6 - 10
State -- position 11 - 12

I'm at a loss how to do this in MS Access. Any suggestions?
 
Create a query that combines the fields like:
Output: Left([Name] & " ",5) & Left(ZipCode & " ",5) & Left(State & " ",2)

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
asanchez4,
You can do this with the built-in I/O functions. For all the details check the Help files, to get you started here is a sample:
Code:
Sub OutputFixedWidthTest()
Dim intMyFile As Integer
Dim TestCounter As Integer

'Get a pointer for the file
intMyFile = FreeFile
'Open/Create the test file in the C direcotry
Open "[i]C:\fixedwidth.txt[/i]" For Output As #intMyFile

'Loop for testing, replace this with your recordset
For TestCounter = 1 To 10
  [green][b]'NOTE: If your text is longer than the space allotted then
  '      the text will print on the next line[/b][/green]
  Print #intMyFile, "Name"; Tab(6); "Zip C"; Tab(11); "ST"
Next TestCounter

'Close the file
Close #intMyFile
End Sub

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top