473,513 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to import from Excel sheet but order gets messed up

Hi again

I am trying to import from an excel spreadsheet into access 2002, but the
order that is in the spreadsheet is not preserved when I import. using
DoCmd.TransferSpreadsheet in code.

Access sets indexes on certain fields with "Code" in the field. Even if I
remove these index, the order is close, but still some of the fields are out
of order.

There is no true order to this spreadsheet, and it must stay in this order.

What can I do?

Thanks again
Nov 13 '05 #1
3 5804
On Sat, 02 Oct 2004 15:42:46 GMT, "Danny" <da********@hotmail.com>
wrote:

So it should stay in this "no true order", huh?

I would add a column: LineNumber, and import that as well. Then in
Access you can sort by that column.

I think the Auto-Index feature of Access is mostly more of a
hindrance. Turn it off in Tools/Options/Tables-Queries/AutoIndex.

-Tom.
Hi again

I am trying to import from an excel spreadsheet into access 2002, but the
order that is in the spreadsheet is not preserved when I import. using
DoCmd.TransferSpreadsheet in code.

Access sets indexes on certain fields with "Code" in the field. Even if I
remove these index, the order is close, but still some of the fields are out
of order.

There is no true order to this spreadsheet, and it must stay in this order.

What can I do?

Thanks again


Nov 13 '05 #2
Simple solution. Add an autonumber primary key to your table and
you're done. The PK will determine the sort order, and will force the
records to remain in import order. I think you're making a
fundamental mistake about database tables - they're *inherently
unordered*. If you want them ordered, apply a filter or open a query
based on the table... In Excel you can do something like this:

A3=A2-1
(This record's value equals the value of the previous record minus
one.) Doing that in Access, you need to specify a sort order as there
is no inherent record order in your table...
Nov 13 '05 #3
pi********@hotmail.com (Pieter Linden) wrote ...

Your reply is slightly confused:
Simple solution. Add an autonumber primary key to your table and
you're done.
You are assuming the table currently has no primary key, which would
be unusual (technically, it would be a heap rather than a table <g>).
You could've simply suggested adding a IDENTITY/autonumber column, but
why make it the primary key?
I think you're making a
fundamental mistake about database tables - they're *inherently
unordered*.


I think you meant to say, 'if no ORDER BY clause is specified, their
order is not guaranteed'. In practice, the 'default' order will be the
table's physical order (i.e. order on disk) which is determined by the
clustered index. For Jet, the primary key is the clustered index but
new rows are only physically reordered when the database is compacted.

Rather than rely on coincidence and default behavior, it would be
better to add an explicit row ID to the Excel data and ensure this
imported into the database.

Jamie.

--
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3653
by: Elaksomfan | last post by:
Hi, I am having trouble importing data from an excel spreadsheet into MS SQL Server 2000 using DTS Wizard. The DTS import process is successfull, no errors, but only 50 rows of approx. 1500 rows...
6
12468
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
2
3974
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType =...
10
11793
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
2
3481
by: madeleine | last post by:
I'm hoping the answer to this is that I'm just doing something silly, but I'm really scratching my head over this one. I'm importing data from multiple workbooks, each workbook has a sheet called...
8
8561
by: FireGeek | last post by:
I have a database that is split appropriately. Annually, we need to add data from .xls files. I have added code so with a click of a button, it will import this data as a new table into the...
1
8695
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
11
5358
by: MD | last post by:
Hello, I need to import a sheet of 884 different excel-file with same lay- out. The sheet name is 'Totaal' and is the same in all different files. Is there a script (module) in order to: 1....
7
12039
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
7269
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
7394
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
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
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
4756
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...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.