473,411 Members | 2,285 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,411 software developers and data experts.

Convert column result to rows

48
Dear expert,

I need to make a report where multiple faults and multiple resolutions for a single repair are displayed as a single row. The report will contain about a thousand repairs with an average of 4 faults and 3 resolutions per repair. The number of faults and resolutions are variable and do not need to be the same.

Situation now: attachment queryresult.gif
Should be: attachment targetresult.gif (had to skip a couple of fields to match the max. attachment resolution of 1024x768)

This thread kinda covers the subject..
http://www.thescripts.com/forum/thread191519.html

Hope you can help me out.. Sander
Attached Images
File Type: gif queryresult.GIF (13.3 KB, 682 views)
File Type: gif targetresult.GIF (6.6 KB, 610 views)
Aug 22 '06 #1
4 7211
PEB
1,418 Expert 1GB
Hi,
Your goal is to do: every fault with every possible resolution, isn't it!
IS IT possible to do the union between the 2 fields, devided between them for exemple with _

So you can place this single column as a column heading in a crosstab query and u'll have the columns! But your data won't be so readable! And I don't know if you can exceed more than 255 columns!

But however u'll have instaed 2 columns by row 1 column with the information from the 2!
Aug 29 '06 #2
sanniep
48
PEB, thanks for your reply! Your solution almost covers my needs but, as you mentioned, won't make the report very readable. There are about 100 fault- and about the same number of resolutioncodes in those 1000 repairs so this would give me a table with 200+ columns.

I guess the only solution is a vb-script that creates the necessary columnheaders (fault 1, fault 2, fault 3, resolution 1, resolution 2, etc.) and moves the data from vertical to horizontal rows. Kinda like a Excel-macro that says "cut A2 to B2, A3 to C2, A4 to D2 and so on". It doesn't have to be dynamic columncreation, 10 fixed fault and resolution-columns is fine.

My goal is to get a single row for a repairorder with 10 columns (5 faultcodes, 5 resolutioncodes) filled with data.

Thanks for the help so far! Sander
Aug 29 '06 #3
PEB
1,418 Expert 1GB
Hi,
Reelly you can do a VB script that creates a table with the needed columns! There is a small danger! IN MS ACCESS you can create only 255 columns! If your data becomes important you aren't be able to fit it into the table!

In fact if you create the previous crosstab query, then a script that creates a table based on a column from query, you can populate this table using an Append Query that contains a function like Mid(mystr,1, instr(1,mystr,"_")-1) to separate the values from the crosstab.

Some expressions that can help you crating your VB script:

Set DefaultWorkspace = DBEngine.Workspaces(0)
Set CurrentDatabase = DefaultWorkspace.Databases(0)
Set MyTableDef = CurrentDatabase.CreateTableDef(tabl_name)

Set MyField = MyTableDef.CreateField(myrec("[" + Field_name + "]"), myrec("[" + type_name + "]"))

MyTableDef.fields.Append MyField
CurrentDatabase.TableDefs.Append MyTableDef

Have a nice day
Aug 30 '06 #4
sanniep
48
Peb!

I think I've accidently deleted the mail confirming the posting of your reply. Didn't have a clue you answered the post..

I will look into your advise right away, thanks!

Regards, Sander
Sep 12 '06 #5

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

Similar topics

2
by: Wayne Pierce | last post by:
I have a small script with PHP that queries a MySQL database to pull out one row, where I want to be able to access each of the columns separately. I have tried several different variations and am...
0
by: Harry Haller | last post by:
The context is shown below in the getGames() method. I get errors on these lines: dtGames.Rows = (TimeSpan)dtGames.Rows; dtGames.Rows = (DayOfWeek)dtGames.Rows; because the playDate column...
2
by: Mattyw | last post by:
Hi I have a sqlcommand that returns all the rows in a column and then pass that to a datareader. I am new to VS.Net and so far I can only return the first row in the first column using ...
5
by: Silvio Matthes | last post by:
Hello, I'm new to the list and did not find a suitable answer to my question so here it is: I try to select the rows of a table where the content of a varchar-column is empty ('') and...
5
by: needin4mation | last post by:
Hi, I have a webservice that just returns a count: public DataSet HelloWorld() { OdbcConnection conn = new OdbcConnection("DSN=xxx"); String sqlString = "select count(*) as employee from...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
3
by: italia | last post by:
I have a database with 2 columns and more than million rows. The first column is the id Example of the data (2 columns)- 04731 CRM 04731 CRM 04731 CRM 04731 RVB 04731 RVB
2
by: kirke | last post by:
Hi, I have a datetime column named dtDateTime. its format is "Oct 27 2006 12:00:00 " I want to group by only date part of it and count my code is $sql1="SELECT ...
2
by: Ch Pravin | last post by:
Hi All: I am having the following xml which i need to convert to excel using xslt. Please help me out. Afghanistan.xml <?xml version="1.0" encoding="utf-16"?> <Languages...
2
by: CodeMonkey775 | last post by:
I'm having problems passing a variable to a method which is executed and compiled using CodeDom. The situation is I have a List<CellData> with cells, each containing a formula (like Excel). I am...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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.