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!

Importing Text file with Extra Delimiters - how to delete?

Status
Not open for further replies.

lobo3101

MIS
Aug 26, 2008
7
US
I'm importing text files that are comma-delimited. Unfortunately, the software that creates these files drops 2 extra commas in at the end of each line. This throws off my import and Access sees a "No Name" field there.

What's the best way to delete these commas? Is there an RTrim that'll read in the text file and delete the last 2 characters of each line?

I'm using "DoCmd.TransferText acImportDelim..." to load these texts into tables.

Here's an example of a line:
800.55,0,Alpha.450,1,Open,,

Those last 2 commas need to come out of every line in the text file.
 
Why not create an import specification with Skip selected for the last field?
 
Yanno, I'm not familiar with that specification. I tried to search google on it but couldn't come up with anything solid.

Could you provide anymore detail?
 
Import a text file manually and choose Advanced from the import window. It will allow you to edit and save a specification that can be used with TransferText.
 
I've checked those last 2 fields as "SKIP" in the Advanced portion of Import Table and saved it.

Still receiving this error though:
"Field NoName doesn't exist in table tblHoldings_Exception"

All fields are mapped and accounted for...but I think for some reason those 2 extra commas are still being counted in. Even though I've skipped them.
 
DoCmd.TransferText acImportDelim, HoldingsException, "tblHoldings_Exception", _
"\\Folder\Reports\" & "Holdings Exception Report-" & today & ".txt", True

rstC.Open "select * from tblHoldings_Exception", conn, adOpenDynamic, adLockOptimistic
Do Until rstC.EOF
rstC.Update
rstC.MoveNext
DoEvents

------------------------------
HoldingsException is where I created the Import structure to Skip the last 2 fields.
 
So, is that:

Code:
Dim HoldingsException
HoldingsException="HoldingsException"

or

Code:
DoCmd.TransferText acImportDelim, "HoldingsException", "tblHoldings_Exception", _
        "\\Folder\Reports\" & "Holdings Exception Report-" & today & ".txt", True

In other words, the specification must be a string.
 
That was exactly it! The HoldingsException needed "" around it!!

Thankyou so much. None of the examples I looked at online had quotes there so I didn't think I'd need them. Very good!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top