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

Carriage return causing blanks on import

Status
Not open for further replies.

Cloonalt

Programmer
Jan 4, 2003
354
US
I have a .txt file I'm importing into Access. When it gets imported it has blanks between each line, which I assume is caused by double carriage returns between every other line. I can delete the blank lines once I get it into Acces, but I wonder if there's some way on the import to strip out extra carriage returns. Can I do it in code, rather than the import routine?

Doesn't seem to be, but I thought I'd ask.

Thanks for any help.
 
Sure you could, but I think it would be a lot easier to use a delete query, which would take about 5 seconds to write.
 
How are ya Cloonalt . . .

Agree with [blue]MajP[/blue], however I would use the following routine to strip the extra lines completely throughout the file:
Code:
[blue]Public Function NoDblLines(Dat As String)
   Dim NL As String, DL As String
   
   NL = vbNewLine
   DL = NL & NL
   
   NoDblLines = Replace(Dat, DL, NL)

End Function[/blue]


Calvin.gif
See Ya! . . . . . .
 
Hate to ask dumb question, but...

What is data in this scenario?

Thanks for your help.
 
Cloonalt . . .

Dat is the variable or form control name which holds the file. Say you load the file into a memo field named [blue]MyFile[/blue] on a form. To strip the extra blank lines you'd have:
Code:
[blue]   Me!MyFile = NoDblLines(Me!MyFile)[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top