473,394 Members | 1,640 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,394 software developers and data experts.

Importing a CSV file? Erroring out

133 100+
The line below codes the vba code that keeps erroring out with a "[31519]: You cannot import this file" message. According to the Access 2003 VBA Language Reference, TransferText Method, the syntax is used correct. expression.TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage.

Expand|Select|Wrap|Line Numbers
  1. expression.TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage.
  2.  
below is my code:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferText acImportDelim, "Credit_Memo", "L:\UH_Warehouse_Reporting\SciQuestData\Credit_Memo.csv", True
  2.  
Any suggestions would be appreciated.
Mar 28 '11 #1

✓ answered by TheSmileyCoder

The importspec is the details of how the import is meant to run. For instance, in the DoCmd.Transfertext, you have specified that there is a delimiter, but you have not specified what the delimiter is! Such a thing among others are specified in an import spec. If you manually import the file the first time, you can specify such settings, and then save the import spec.

8 5976
TheSmileyCoder
2,322 Expert Mod 2GB
Does the import work when you do it manually?
Mar 28 '11 #2
dowlingm815
133 100+
yes, i can import it in access as a csv file.
Mar 31 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
You seem to be missing an argument in your syntax. ITs either the specification name or the table name.
Apr 1 '11 #4
dowlingm815
133 100+
i can't seem to locate the error. the credit_memo and the path file appear to be intact.

for time efficiency, the statement was converted into an excel import statement.

however, i welcome any suggestions.
Apr 5 '11 #5
TheSmileyCoder
2,322 Expert Mod 2GB
Did you fix the missing argument?
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.TransferText _
  2.         transferType:=acImportDelim, _
  3.         SpecificationName:="Credit_Memo", _
  4.         TableName:="", _
  5.         FileName:="L:\UH_Warehouse_Reporting\SciQuestData\Credit_Memo.csv", _
  6.         HasFieldNames:=True
From your code, I can't guess whether Credit_Memo is your table name or the name of your importspec, but one or the other is missing. I have typed it out differently for you, which may make it more clear what is happening.
Apr 5 '11 #6
dowlingm815
133 100+
i'm having difficultly understanding what an import spec is? the credit_memo is the name of the access table. The following is the vba procedure in full, line 48 is where the executable statement is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ImportRecords()
  2.  
  3. On Error GoTo Err_Hndlr
  4.  
  5.  
  6.     If TableExists("SO_Data") Then
  7.     ' delete the table if it exists
  8.         DoCmd.DeleteObject acTable, "SO_Data"
  9.     End If
  10.     If TableExists("SO_Data$_ImportErrors") Then
  11.     ' delete the table if it exists
  12.         DoCmd.DeleteObject acTable, "SO_Data$_ImportErrors"
  13.     End If
  14.  
  15.  
  16.     If TableExists("SO_CFHeader") Then
  17.     ' delete the table if it exists
  18.         DoCmd.DeleteObject acTable, "SO_CFHeader"
  19.     End If
  20.     If TableExists("SO_CFHeader$_ImportErrors") Then
  21.     ' delete the table if it exists
  22.         DoCmd.DeleteObject acTable, "SO_CFHeader$_ImportErrors"
  23.     End If
  24.  
  25.     If TableExists("Credit_Memo") Then
  26.     ' delete the table if it exists
  27.         DoCmd.DeleteObject acTable, "Credit_Memo"
  28.     End If
  29.     If TableExists("Credit_Memo$_ImportErrors") Then
  30.     ' delete the table if it exists
  31.         DoCmd.DeleteObject acTable, "Credit_Memo$_ImportErrors"
  32.     End If
  33.  
  34.  
  35.     MsgBox "Please be patient while application is uploading the contracts.", vbInformation
  36.  
  37.  
  38.     ' import file
  39. '    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "SO_Data", "L:\UH_Warehouse_Reporting\SciQuestData\SO_Data.xls", True
  40. '    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "SO_CFHeader", "L:\UH_Warehouse_Reporting\SciQuestData\SO_CFHeader.xls", True
  41. '    'DoCmd.TransferText acImportDelim, "Credit_Memo", "L:\UH_Warehouse_Reporting\SciQuestData\Credit_Memo.csv", True
  42. '    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Credit_Memo", "L:\UH_Warehouse_Reporting\SciQuestData\Credit_Memo.xls", True
  43. '
  44. '    FOR TESTING PURPOSES
  45.  
  46.     DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "SO_Data", "C:\Documents and Settings\DowlinMM\My Documents\Development\UH Mgt Inventory Rptg\UH Mgt Inventory Rptg\Sciquest Data\SO_Data.xls", True
  47.     DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "SO_CFHeader", "C:\Documents and Settings\DowlinMM\My Documents\Development\UH Mgt Inventory Rptg\UH Mgt Inventory Rptg\Sciquest Data\SO_CFHeader.xls", True
  48.     'DoCmd.TransferText acImportDelim, "Credit_Memo", "L:\UH_Warehouse_Reporting\SciQuestData\Credit_Memo.csv", True
  49.     DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Credit_Memo", "C:\Documents and Settings\DowlinMM\My Documents\Development\UH Mgt Inventory Rptg\UH Mgt Inventory Rptg\Sciquest Data\Credit_Memo.xls", True
  50.  
  51.  
  52.     MsgBox "Task Complete!", vbInformation
  53.  
  54. ImportRecords_Exit:
  55.   Exit Sub
  56.  
  57.  
  58. Err_Hndlr:
  59.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "ImportRecords()"
  60. End Sub
  61.  
Apr 5 '11 #7
TheSmileyCoder
2,322 Expert Mod 2GB
The importspec is the details of how the import is meant to run. For instance, in the DoCmd.Transfertext, you have specified that there is a delimiter, but you have not specified what the delimiter is! Such a thing among others are specified in an import spec. If you manually import the file the first time, you can specify such settings, and then save the import spec.
Apr 5 '11 #8
dowlingm815
133 100+
It took a bit a digging, but the following link is how to create an export /import specification in MS Access. My error is that I was looking to code it:

http://www.blueclaw-db.com/export-specifications.htm
Apr 13 '11 #9

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

Similar topics

1
by: Emil Karlen | last post by:
Using the import-tag, a template appearing in the imported file, can be extended in the importing file. I am extending a template this way and in the main-file, inside the template use...
11
by: David Lozzi | last post by:
Hello, I need to automate importation of a excel file into a table. Here's my scenario: I'm writing an ASP.NET application where users can pull reports on imported data. The imported data is...
1
by: Tim Gains | last post by:
can someone instruct me as to how to load a binary file and the import it's data (rows pf data) into a database? Do I need to convert the binary file in any way in order to decipher it's data. Any...
6
by: gmarkowsky | last post by:
Hi all, I'm trying to import a class from a module. The class looks like this: class App: def __init__(self, master): frame = Frame(master) frame.pack()
6
by: owz | last post by:
I am trying 2 load details about cars from a.txt file and then display the total stock value off all cars. public class Car { // attributes private String manufacturer; private...
2
by: runway27 | last post by:
presently i have a table in which there are records and the fields are slno (this is a primary key auto increment), firstname, lastname, email, date(which inserts as a date format) these records are...
1
by: Sudhakar | last post by:
presently i have a table in which there are records and the fields are slno (this is a primary key auto increment), firstname, lastname, email, date(which inserts as a date format) these records...
5
by: thread | last post by:
hi all does anyone knows how to import/link a file that sits on a server for now everytime im trying to import,im getting a message connect to server but then it is cenceled any ideas
6
by: passionateforjava | last post by:
Hi All, I am using struts application wherein I need to import file for some purpose.I have used input type="file" for the same which goes like: <input type="file" id="uploadFile" name="uploadFile"...
2
by: squirrelknight | last post by:
Hello. I am new to Python. I've just installed version 3.0.1, which I will be using on a Linux box (which I am also new to), and need to use it to essentially call on several files of a specific...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.