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

Error in data import? It's worked using this template several times prior!

geolemon
Import text wizard says:
"The first row contains some data that can't be used for valid Access field names. In these cases, the wizard will automatically assign valid field names"
I'm banging my head on this one, here's why:
I've been importing files using this process and data format, with success!

I created a temporary table in Access to facilitate my import process (It's all text columns, I perform transformations later).

And I created a template in Excel to correspond to the table - essentially it's just column headers:
In Excel, I've been opening files of work that we've done for a particular customer, and rearranging the data to conform to my template. Then, each job's data is ready for import!

So in other words - the data that I started with is common format, and I'm using my "template" to create files of common format that correspond to the temp table.

And
This worked for 3 or 4 of the files. No problem.

The puzzling thing is that all of a sudden, one of my files gave me an error last night:
"The first row contains invalid data"
Or something along those lines.

So after sleeping on it, this morning I decided to try working around the issue by exporting my Excel as a tab-delimited file.

Now, the wizard is throwing the exact error message above...
...And although THIS way at least I can get through the wizard to the end and click a "Finish" button - it throws a "Property not found" error, and then "An error occurred trying to import file [my file path]. The file was not imported."
I'm very puzzled!

Particularly - how could this work for three files having exactly the same header row, and suddenly fail now?
Exported to text, and still an issue?

(worse - I need to develop this into a repeatable process to pass on to an administrative user!)
Sep 12 '08 #1
5 5846
PS-
I haven't explored the "linked tables" option because it doesn't seem to be set up for the purpose of avoiding errors like these, and I'm not familiar with it. It also creates additional complexity (read: "opportunity for error").
I'm also concerned that taking this data (currently stored discretely per-job in appropriately distinct locations) and exporting it to a common location would potentially violate something in ISO processes..
Sep 12 '08 #2
"Method 'Columns' of object 'IImexGrid' failed
is the error message I originally got directly importing this one particular Excel file, followed by
The first row contains some data that can't be used for valid Access field names. In these cases, the wizard will automatically assign valid field names.
The header row is as follows:
RefID
DNP
CustPN
BOMPN
PurchasedPN
PNSource
Manufacturer
Description
Sep 12 '08 #3
Eureka!!!!

I decided to just let it fly - import it into a NEW table, and I found something:

It was trying to import two extra columns (to the right of the ones I listed), and 30 or 40 extra rows of data (all blank cells, I presume from below the rows that were actually populated - although when I opened the table they appeared at the top.

I deleted the extra rows and columns, and was able to insert without problem into my "real" temp table and finish the processing routine from there.

So, the real question is this:
How does Access know what rows/columns to import?
I assumed it was just based on what was filled in, if not explicitly specified.

I don't really have a means of explicitly specifying it in this process I'm trying to develop, so it would really help to understand the logic Access uses when it isn't explicitly given.

Thanks in advance for insight!
Sep 12 '08 #4
Stewart Ross
2,545 Expert Mod 2GB
Hi geolemon. I'm glad this worked out for you in the end.

Access uses Excel's internal properties (such as the LastCell address) to determine the overall range imported, as it is the rectangular region starting at range A1 and ending at the last cell that is imported. From the last column address Access can work out what cells to read in the first row as field names.

It would appear that Access found values it could not accept beyond the columns you expected. A cell looking blank does not necessarily mean it is empty! It could contain any non-printable chracter, or spaces for instance, and you would not notice it or know it was there unless you selected the whole spreadsheet to see what the actual range was (using Crtl-End to go to the last cell).

Where the data imported has a header row it defines the field names created by Access. The ones you quote in your post are fine, and Access will normally change certain invalid characters that cannot be used in field names to ones it can accept (for instance, the period character, as in 'ABC.DEF', is I think changed to an underscore, as in 'ABC_DEF'.

Beyond that it is not really possible to speculate without seeing the sheet directly.

-Stewart
Sep 12 '08 #5
So possibly there was a space or other non-visible character an those columns, somewhere?

Thinking "I need to make this a repeatable process", then you'd speculate with me that either of these precautions would work, right:

Either one:
  • Highlight "a good number" of columns to the right of "Description" and press "Delete, and highlight a "good number" of rows below my last completed row and press "Delete" - to clear alll those cell's contents
  • Highlight the range of cells I want to import, in the columns I want, "copy" and "paste" them into a new, virgin worksheet by clicking on cell A1 and doing a "paste" (or "paste values")

I've written a form for a user to browse to an Excel file, populates a text box with the path, and have an "upload" button to DoCmd.TransferSpreadsheet...
I wonder if I should use the "range" variable in that command to limit the spreadsheet only to those columns? The problem that I see with that is if I state an explicit range like that, if Access will then try to import all 65536 rows?

One other annoyance is that when Access does try to import "extra" rows, it throws a primary key "duplicate records" error. Such an error would scare an end user silly - and certainly even with me, it causes me to go back to the Excel worksheet, reorder my data and perform a search for duplicate keys to make sure I don't have any! THEN I know I can ignore it, but it breaks a process that an end user would be expected to handle.
Sep 12 '08 #6

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

Similar topics

5
by: Andrew Lowe | last post by:
Hi all, First off, I'm new to the Oracle world so please be gentle on me. Now down to the problem at hand. I support a CAD application that has an Oracle backend. I've been on site at my clients...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
0
by: Patrick A | last post by:
All - 2 questions, the answer to either one having the possibility of making the other a moot point: 1. I have a DB with a form that serves as a GUI to let the user browse for an XML file and...
9
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the...
6
by: sara | last post by:
I have a procedure to automate bringing several Excel files into our Access tables, on a daily basis. The problem is that if the user has a problem, and tries to run the import again (maybe 3...
4
by: andrewcw | last post by:
I am moving some code forward from .NET 1.1. I was able to load the XSL file and perform the transform. The MSDN documentation looks like it should be easy. But I get a compile error. Ideas ?...
0
by: Alun Jones | last post by:
I'm getting the above error in a dialog box from Visual Studio 2005 when trying to sign an assembly using a PFX file, and would like to know how to resolve the problem. Background: The PFX...
1
by: hn.ft.pris | last post by:
I have the following code: Tree.h defines a simple binary search tree node structure ########## FILE Tree.h ################ #ifndef TREE_H #define TREE_H //using namespace std; template...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.