473,785 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transposing columns into rows in access

Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help
--
Kindest Regards

Tom
Tom McCay (Director)
Classic-Car-World Ltd
Tel: 01522 888178
FAX: 0870 705 9115
E-Mail: to*@classic-car-world.co.uk
URL: www.classic-car-world.co.uk

Now offering quality Sealey & Draper tools at discount prices, see
www.ccw-tools.com for further details.
Sep 14 '06 #1
9 10668
On Thu, 14 Sep 2006 14:10:26 GMT, "Classic-Car-World Ltd"
<en*******@clas sic-car-world.co.ukwrot e:

Use the often-quoted fConcatChild from here:
http://www.mvps.org/access/modules/mdl0004.htm

-Tom.

>Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help
Sep 14 '06 #2
The cross tab query wizard should be able to do it.

"Classic-Car-World Ltd" <en*******@clas sic-car-world.co.ukwrot e in message
news:mp******** *********@newsf e3-gui.ntli.net...
Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help
--
Kindest Regards

Tom
Tom McCay (Director)
Classic-Car-World Ltd
Tel: 01522 888178
FAX: 0870 705 9115
E-Mail: to*@classic-car-world.co.uk
URL: www.classic-car-world.co.uk

Now offering quality Sealey & Draper tools at discount prices, see
www.ccw-tools.com for further details.


Sep 14 '06 #3
Thanks Ron, tried the cross tab query but it didn't work.

--
Kindest Regards

Tom

"paii, Ron" <pa**@packairin c.comwrote in message
news:1O******** *************** *******@athenet .net...
The cross tab query wizard should be able to do it.

"Classic-Car-World Ltd" <en*******@clas sic-car-world.co.ukwrot e in
message
news:mp******** *********@newsf e3-gui.ntli.net...
>Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is
currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help
--
Kindest Regards

Tom
Tom McCay (Director)
Classic-Car-World Ltd
Tel: 01522 888178
FAX: 0870 705 9115
E-Mail: to*@classic-car-world.co.uk
URL: www.classic-car-world.co.uk

Now offering quality Sealey & Draper tools at discount prices, see
www.ccw-tools.com for further details.



Sep 15 '06 #4
Hi Tom, I wish I understood what this was. I'm sure it would work but
unfortunately I don't understand the finer art of coding. Is it a simple
matter of running the code as a query against the one table and what
modifications would I need to make to link it to my table. Is it just a
matter of changing the field names?

--
Kindest Regards

Tom

"Tom van Stiphout" <no************ *@cox.netwrote in message
news:85******** *************** *********@4ax.c om...
On Thu, 14 Sep 2006 14:10:26 GMT, "Classic-Car-World Ltd"
<en*******@clas sic-car-world.co.ukwrot e:

Use the often-quoted fConcatChild from here:
http://www.mvps.org/access/modules/mdl0004.htm

-Tom.

>>Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help

Sep 15 '06 #5
This may be a clumsy way to do it, but why not try this....

Set up your new table, making the Product No the Primary Key. Name the other
Columns: Order, Description, Model_No, Size, and Length. Import the existing
table. Of course, it will only import the first of each Product No. along
with its Order, Description, and Model_No. The last two will be null. When
you get the warning message that not all of your data could be imported,
ignore it.

Go back into table design mode and delete the fields Order and Description.

Next, set up an update query with a relationship between the old table and
the new one based on the Product Key. The criteria for selecting records from
the old table would be [order] = 2. Then just have it update the Size field
of the new table with the Value field from the old table. Execute the query.
Go back to Design mode and replace the search value in the order field of the
old table to be [order] = 3. Remove the Size field from the query and add the
Length field. Have it updated with the value of the Value field.

Not elegant, but it should work, I think.

Classic-Car-World Ltd wrote:
>Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help
Sep 15 '06 #6

Create 2 queries, the 1st named zQtest conditions and sorts the data in a
table named zTest.

SELECT zTest.ProdNo, zTest.Order, [Desc] & ", " & [Value] AS Col
FROM zTest
ORDER BY zTest.ProdNo, zTest.Order;

Use this for the cross tab

TRANSFORM First(zQTest.Co l) AS FirstOfCol
SELECT zQTest.ProdNo
FROM zQTest
GROUP BY zQTest.ProdNo
PIVOT zQTest.Order;
"Classic-Car-World Ltd" <en*******@clas sic-car-world.co.ukwrot e in message
news:XM******** *********@newsf e7-win.ntli.net...
Thanks Ron, tried the cross tab query but it didn't work.

--
Kindest Regards

Tom

"paii, Ron" <pa**@packairin c.comwrote in message
news:1O******** *************** *******@athenet .net...
The cross tab query wizard should be able to do it.

"Classic-Car-World Ltd" <en*******@clas sic-car-world.co.ukwrot e in
message
news:mp******** *********@newsf e3-gui.ntli.net...
Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is
currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help
--
Kindest Regards

Tom
Tom McCay (Director)
Classic-Car-World Ltd
Tel: 01522 888178
FAX: 0870 705 9115
E-Mail: to*@classic-car-world.co.uk
URL: www.classic-car-world.co.uk

Now offering quality Sealey & Draper tools at discount prices, see
www.ccw-tools.com for further details.



Sep 15 '06 #7
Hi I think I understand what you are trying to do here but can you tell me
the expression I have to enter in the "Update To" field that will allow me
to specify the appropriate field in the old table.

I've completed the first part but can't see how to set up the final update
in the update query.

Sorry about this, but I don't really have any access skills.

--
Kindest Regards
Tom

"GMForsythe " <u26679@uwewrot e in message news:6655e98775 ea0@uwe...
This may be a clumsy way to do it, but why not try this....

Set up your new table, making the Product No the Primary Key. Name the
other
Columns: Order, Description, Model_No, Size, and Length. Import the
existing
table. Of course, it will only import the first of each Product No. along
with its Order, Description, and Model_No. The last two will be null. When
you get the warning message that not all of your data could be imported,
ignore it.

Go back into table design mode and delete the fields Order and
Description.

Next, set up an update query with a relationship between the old table and
the new one based on the Product Key. The criteria for selecting records
from
the old table would be [order] = 2. Then just have it update the Size
field
of the new table with the Value field from the old table. Execute the
query.
Go back to Design mode and replace the search value in the order field of
the
old table to be [order] = 3. Remove the Size field from the query and add
the
Length field. Have it updated with the value of the Value field.

Not elegant, but it should work, I think.

Classic-Car-World Ltd wrote:
>>Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help

Sep 15 '06 #8
What if you wrote a simple routine to unstack your data?
Something like:

Create a second table with fields of ProductNumber, Description, size and
length

Open the old table as recordset1
Open the new file as recordset2

do while not recordset1.EOF
recordset2.appe nd
recordset2!Prod uctNumber = recordset1!Prod uctNumber
recordset2!Desc ription = recordset1!Desc ription & " " &
recordset1!valu e
recordset1.move next
recordset2!size = recordset1!valu e
recordset1.move next
recordset2!leng th = recordset1.Valu e
recordset2 update
recordset1.move next
Loop

This assumes that the data for each item is limited to exactly three records
and that the data is
sorted by partno and the order just as you depict it.

"Classic-Car-World Ltd" <en*******@clas sic-car-world.co.ukwrot e in message
news:mp******** *********@newsf e3-gui.ntli.net...
Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc


Sep 15 '06 #9
Hi Just to say thank you to those who responded to my plea for help. I
managed to achieve the desired results by running the update query as
described below.

Thanks again

--
Kindest Regards
Tom

"GMForsythe " <u26679@uwewrot e in message news:6655e98775 ea0@uwe...
This may be a clumsy way to do it, but why not try this....

Set up your new table, making the Product No the Primary Key. Name the
other
Columns: Order, Description, Model_No, Size, and Length. Import the
existing
table. Of course, it will only import the first of each Product No. along
with its Order, Description, and Model_No. The last two will be null. When
you get the warning message that not all of your data could be imported,
ignore it.

Go back into table design mode and delete the fields Order and
Description.

Next, set up an update query with a relationship between the old table and
the new one based on the Product Key. The criteria for selecting records
from
the old table would be [order] = 2. Then just have it update the Size
field
of the new table with the Value field from the old table. Execute the
query.
Go back to Design mode and replace the search value in the order field of
the
old table to be [order] = 3. Remove the Size field from the query and add
the
Length field. Have it updated with the value of the Value field.

Not elegant, but it should work, I think.

Classic-Car-World Ltd wrote:
>>Hi, I have some data in a table in columns which I need to convert into
rows. This is specification data for some tools etc. The data is currently
in the following format:

Product No, order, description, value

1000, 1, model No, Ak272
1000, 2, Size, 10mm
1000, 3, Length, 20mm
1001, 1, Model No, Ak273
1001, 2, Size, 25mm
1001, 3, length, 50mm
etc
The format I require the data in is as follows:

Product No, Col1, Col2, Col3
1000, Model No AK272, Size 10mm, length 20mm
1001, model No AK273, Size 25mm, length 50mm
etc

I have approximately 5,000 records to sort in this way.

Thanks in advance for any help

Sep 15 '06 #10

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

Similar topics

4
1442
by: shank | last post by:
Is the CASE statement allowed when querying an Access database? Assuming so, what is the correct syntax? thanks SELECT OrderNo, Description, Type, Label FROM Stock WHERE Manuf = 'M' ORDER BY CASE 'C' WHEN 'orderno_asc' THEN OrderNo END ASC, CASE 'C' WHEN 'description_asc' THEN Description END ASC,
3
1514
by: John Spiegel | last post by:
Hey all, I can't seem to find a way to determine how many columns or rows are in a multi-dimensional array. The Length and Rank properties would seem to help, but I can't seem to find that missing piece. Any ideas? TIA, John
3
13360
by: jeffgeorge | last post by:
Trying to split a column in Access with all fields having the format: COLUMN: I see in Excel they have a Text to Columns function which creates two columns which seperate the NUMBER and NAME. Does Access have this functionality. Can kick it out to Excel but I'm over the 65,000 rows and would have to split, etc.
1
10313
by: Richie | last post by:
I am working with an Access table that contains dollar amounts in two columns, one for January 2004 (CP_Payment_01 ) and the other for February 2004 (CP_Payment_02). My original goal was to take this table – and example of which is below - and sum the values in each by Vendor Nbr. Table: RealEstateRent Company Vendor_Group Vendor Nbr Vendor Name CP_Payment_01 CP_Payment_02 ------- ------------ ---------- ----------- ...
2
5087
by: Dscar | last post by:
Hi, I am a beginner in ACCESS, I've imported data into access, and then realized that I need to split the information in one of my columns into 2 columns. the information looks like this: 00700400000000 00700400001230 00700400102000 I would like 007004 in one column and the rest of the info in another column. I know in excel I could do text to columns, however the is 20,000 records in access and can not export to excel and split the info. ...
1
3704
by: omnittha | last post by:
Hi! Here I need help from you all - I would like to add values in 2 columns and write them to a third column and get the avg value of the third column. For Example: ColumnA ColumnB ColumnC 1 5 6 2 6 8
1
11310
by: brionesl | last post by:
Hi, I have seen other threads with the same question but I'm not too familiar with Access and their solutions often include writing VB code or very complex SQL statements. What I want to do is display each city in which there are offices as columns and the respective user names in rows underneath the columns. This is how the data needs to appear in Excel: New York San Diego Kansas City Smith, John Smith, Jane Correia, Sabrina Brown,...
1
2770
by: ragulan84 | last post by:
I have to compare columns in MS acces. Please see below the sample LAST_NEWSLETTER_OPENED_DATE LAST_LOGIN_DATE 07/21/09 06/26/09 07/21/09 12/29/09 12/31/08 12/08/09 12/15/09 There are hundreds of field in each column. I want to filer out the fields where login date and newsletter opened dates are same. How to do that? Pls help me.
5
5160
by: nedryerson | last post by:
Hello, I'm working on a form in Access 2007, and specifically on a combo-box field that displays two columns in the drop-down menu. The problem is that once I make a selection, the field only displays one of the two columns in the filled out box (the column on the left). I'd like to have both columns displayed after making a selection. Does anyone how I can achieve that? Thanks in advance. John
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10087
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7496
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4046
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 we have to send another system
3
2877
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.