473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DoCmd.TransferText fails sometimes

1
hi everyone:

i am trying to import an csv file from internet to my database.

i use these vars:

myurl= "www.heresmyfile/table.csv"
mypath= "C:\users\me\table.csv

'i use the API function URLDownloadtofile to download the
'csv file to my hard disk

anything=URLDonwloadToFile(0, myurl, mypath,0,0)

'later, i use DoCmd.TransferText to pick the created
'csv file and insert to my bd as a table

DoCmd.TransferText acImportDelim, "Table_name", mypath, true

this program has a loop (about 2000 iterations), it runs good for the first 5 or 6 iterations, then show the error message (it is not exactly cause my office is in another language, beg ur pardon for my traslation):

"runtime error 3051:
the microsoft access database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.

i read about some ppl who had a similar trouble. i created the function SLEEP to give more time for the DoCmd.TransferText execution. it works, but i have to give more than 3 seconds (SLEEP 3000) to avoid the error, which it happens anyway, but less frequently. And the program takes more time to complete.

Thanks in advance
Oct 13 '15 #1
3 2453
jimatqsi
1,271 Expert 1GB
Is it possible to know how many rows should be imported? You could query the import destination file to ascertain completion before looping to the next file.

Jim
Oct 16 '15 #2
Rabbit
12,516 Expert Mod 8TB
Or check that the download is finished before trying to import it.
Oct 16 '15 #3
NeoPa
32,556 Expert Mod 16PB
It seems to me you have two fundamental options if, as seems the case, your file is still downloading at the point that you try to import it :
  1. Open the file (Using Open #) with the Exclusive option first.
    Loop around until this is possible.
    Include a DoEvents statement within the loop (Not SLEEP).
  2. Attempt to rename the file to itself before doing the Transfer.
    Again, loop with DoEvents until it works.
Oct 16 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Teresa | last post by:
I'm trying to import a tab delimited text file. The text file does not have column heading. I can give it column heading if needed. How do I change the defult comma delimited to tab? If I...
3
by: holdemfoldem | last post by:
Hi. I'm new to this board and have a few questions about using the method referred to in the topic of this message. I have manually transferred over 1/2 million records from a text file into my...
0
by: Chris | last post by:
Hi, I am using the command below for exporting data to text file. One of the query columns has SINGLE number type with decimal ponts as auto. DoCmd.TransferText acExportDelim,...
14
PEB
by: PEB | last post by:
Hi all, Yesterday i've tried this command: DoCmd.TransferText acExportDelim, "Comma_SEP", "myquery", "D:\Temp\Temp.txt" And it gave me an Error that can't find "D:\Temp\Temp.txt" This...
1
by: amitk | last post by:
Hello, I'm using Access 2002-2003. My application exports an Access table into a text file and then appends the text file with several othet files to generate a final file XXXX.ftm . ...
0
by: Cuaracao | last post by:
This is my code: Code1: 'DoCmd.OpenTable "tblImport" 'DoCmd.TransferDatabase acExport, "dBASE IV", strOutputDir,acTable,"sel_TblImport", strDbfName & ".dbf", False ' DoCmd.Close acTable,...
10
by: sakurako97 | last post by:
hi, i am trying to find out if it is possible to pass the current recordset of a form to DoCmd.TransferText so i can export it as a .csv I know I can use querydefs etc, but it would be a much...
14
jbt007
by: jbt007 | last post by:
Hi All, System: Access 2010, WinXP I have a text file I am importing using the following code: 'Import text report into tblBVRRaw table using the BVRImp Spec... DoCmd.TransferText...
2
by: Mariostg | last post by:
I am having issues importing a space delimited file with DoCmd.TransferText. I created a specification name through File->Get External Data->Import. It all works fine when I import the file via the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.