troubleshooting Question

Error reading text file from VBA

Avatar of bfuchs
bfuchsFlag for United States of America asked on
Microsoft AccessVisual Basic Classic
57 Comments1 Solution416 ViewsLast Modified:
Hi Experts,

I have a code that reads data from a text file and imports into a SQL table, however when some records contains a comma as part of the data then the data gets truncated there and the code fails.
 
The code below is used:
   conn.Open "DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=\\myserver\E\XFER;"
   rs.Open "SELECT * FROM [myfile.txt]", conn, adOpenStatic, adLockReadOnly, adCmdText
    
   rs.MoveFirst
   a=rs.Fields(0)

I am also attaching the sample of data file.
Any idea how to make it work is appreciated.
12-30-14.txt
ASKER CERTIFIED SOLUTION
aikimark
Get vaccinated; Social distance; Wear a mask

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2014

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 57 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 57 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros