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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to import text with leading blanks

Status
Not open for further replies.

Soundsmith

Programmer
Feb 21, 2001
84
US
I need to regularly import several text files which will vary in overall width from month to month. They are fixed width files (data all lined up in columns, no delimiters but CRLF at end of line) but each file, each time, may be different width.

I created tblImport1 with 2 fields, F1, text 255 wide, and recnum, Autonumber field so I can track each line. I tried importing as acImportFixed, but don't understand how to create a specification for 255 char-wide line, so I used this:

Code:
Public Function xferFile(fname As String) As Boolean
Dim xferName As String, fullnam As String, theFile As String
'On Error GoTo xferFile_Error
xferFile = True
fullnam = Trim(fname)
theFile = "tblImport1"
DoCmd.TransferText acImportDelim, , theFile, fullnam, False
etc. -

the import works just fine, except it truncates leading blanks. I don't care about trailing spaces, but I must have the positional accuracy to extract the data.

Is there a simple way to generate a fixed-file schema that I can reference? Or to tell TransferText to not ignore the leading spaces?

Thanks.
Thanks David 'Dasher' Kempton
The Soundsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top