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

Read data from a Text File inccluding leading spaces 1

Status
Not open for further replies.

B827

Technical User
Feb 14, 2002
281
GB
I have a simple problem, but can't find an answer. I have a series of plain text files most lines of which have leading spaces (there are varying numbers of leading spaces). I need to be able to read in the data a complete line at a time into a table and include the leading spaces.

I have tried using the Input command but this trims the leading spaces. I cannot find a way round this problem and hoped someone can point me in the right direction.

Thanks in advance. Sandy
 
Hi Sandy!

Dim Dbs as Database
Dim Rst as Recordset
Dim FileName

Set Dbs = CurrentDb
Set Rst=dbs.OpenRecordset"TableToAddInfo",dbOpenDynaset)

Open "C:\Temp\" & FileName & ".txt" For Input As #1
Do While Not EOF(1)
Line Input #1, LineData
Rst.AddNew
Rst!FieldName = LineData
Rst.Update
Loop
Close #1
Rst.Close

Is this the format of the Input command you used? Let me know...

HTH

Roy
aka BanditWk
Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)
 
Hi Roy,
I knew it would be simple! That solved the problem, I was missing "Line" in the

Line Input #1, LineData

Many thanks you've saved me researching into the night (currently 21:20 in the UK) worth a star in my book

Thanks again Sandy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top