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

How can I transpose a table/query in Access?

I am working with a query that has 6 columns and 101 rows; I would like to transpose the rows and columns. I have tried using a crosstab query but Access limits the row "fields" to 3 and this was not producing the desired output. I saw a comment in a thread about using a pseudo row field as a work around but I do not understand how this works.
Another option I tried is from the following link and attempting method 2: http://support.microsoft.com/kb/202176. I must say I am not a programmer and only have a vague idea of what is going on in the code. However I gave it a shot and entered my query information into the Immediate window. When I selected enter I received an immediate error "3027 record is too large", however a table was created with 101 columns correctly but only 3 of the 6 rows were created and none of the numeric data was populated relating to the rows and columns. At this point I am lost and frustrated and would greatly appreciate any advice you can offer.
Jennifer
Sep 5 '09 #1

✓ answered by ADezii

Jennifer, download the Demo (Attachment) that I have now made available to you. With it you can Transpose any 1 of 3 Tables to a TAB Delimited/Quotes surrounding Strings, Text File. This File can then be easily Imported into Excel.

12 19787
NeoPa
32,556 Expert Mod 16PB
Having followed the link myself, it seems to provide a decent solution for your problem. I'm not sure what you want from us.

I know the concept is not the most straightforward, but if you can't understand it I fail to see how we can help. If there's a specific point you get stuck on ask away, but we can't do your work for you.

We wouldn't even if we did know enough about your particular problem, but we don't anyway, of course.
Sep 6 '09 #2
NeoPa
32,556 Expert Mod 16PB
I've just found your other posted question, which I've replied to. If Excel is an option for you then it is much simpler. Excel does it all for you. Such a facility is not available in Access, even if something can be designed to do the work for you.
Sep 6 '09 #3
ADezii
8,834 Expert 8TB
@jenniferhelen
I agree with NeoPa in that the posted Link is indeed a decent solution. I am revising the code to eliminate the Target Argument. The New Target Name will be the Source Name plus _Transposed. If the Target already exists, it will be Deleted. You will only need to supply a Source Name. If you do not wish to manually supply a Source Name, that can even be eliminated but one step at a time. I will also include all this functionality in a Demo Database for you, so you can get a better picture of everything. Be patient - will see you soon.
Sep 6 '09 #4
NeoPa
32,556 Expert Mod 16PB
ADezii,

Bear in mind there is a parallel thread (How do you successfully transpose rows into columns in Excel?) posted by Jennifer which looks at an alternative approach that doesn't need this to be done within Access as such.

There's no reason you shouldn't go ahead if it's something that grabs you, but just so as you know ;)
Sep 6 '09 #5
ADezii
8,834 Expert 8TB
@NeoPa
Thanks NeoPa, and I am aware of what you have stated. I've developed an Algorithm which should theoretically eliminate all Column restrictions as previously indicated by the OP. This Algorithm does not create a Table or Fields, and is not hampered by Access Table limitations. Access does the Transposing internally, and then outputs the Data to a Comma Delimited File in the same Directory as the Database and named Source & _Transposed.txt. This File can now be easily Imported into a variety of External Applications. It has not been refined at this point but I'll post it anyway in case anyone is interested. Guess I'm just bored! (LOL)!
Expand|Select|Wrap|Line Numbers
  1. Function fTranspose(strSource As String)
  2. Dim MyDB As DAO.Database
  3. Dim rstSource As DAO.Recordset
  4. Dim i As Integer
  5. Dim strBuild As String
  6. On Error GoTo fTranspose_Err
  7.  
  8. Set MyDB = CurrentDb()
  9. Set rstSource = MyDB.OpenRecordset(strSource)
  10. rstSource.MoveLast: rstSource.MoveFirst
  11.  
  12. Open CurrentProject.Path & "\" & strSource & "_Transposed.txt" For Output As #1
  13.  
  14. 'The Transposing is done within this Nested Structure
  15. With rstSource
  16.   For i = 0 To .Fields.Count - 1
  17.     Do While Not .EOF
  18.       strBuild = strBuild & .Fields(i).Value & ", "
  19.       .MoveNext
  20.     Loop
  21.       .MoveFirst
  22.        Debug.Print .Fields(i).Name & ", " & Left$(strBuild, Len(strBuild) - 2)
  23.          Print #1, .Fields(i).Name & ", " & Left$(strBuild, Len(strBuild) - 2)
  24.            strBuild = ""       'reset
  25.   Next i
  26. End With
  27.  
  28. Close #1
  29.  
  30. rstSource.Close
  31. Set rstSource = Nothing
  32.  
  33. Exit_fTranspose:
  34.   Exit Function
  35.  
  36. fTranspose_Err:
  37.   Select Case Err
  38.     Case 3078
  39.       MsgBox "The Object " & strSource & " doesn't exist."
  40.     Case Else
  41.       MsgBox Err.Description, vbExclamation, "Error in fTranspose()"
  42.   End Select
  43.     Resume Exit_fTranspose:
  44. End Function
Sep 6 '09 #6
NeoPa
32,556 Expert Mod 16PB
@ADezii
I expect Jennifer is thanking her lucky stars at the moment that she caught you at an idle moment :D
Sep 6 '09 #7
ADezii,
I am extremely grateful for all the time you spent on my problem. I have spent much time trying to use it but I am very inexperienced in this area. Whenever I try to run the code, I am prompted with a macro box. I do not have any macros in this database so I am not sure what is expected at this point. I entered an "a" at this prompt and then selected the Create button (the only other option was the Cancel button). The result was the following text was added after your code, "sub a() end sub".
Again I really appreciate all you have done.

NeoPa,
I appreciate your comments as well and I never meant to imply I wanted anything done for me. I apologize if I offended you.

Regards,
Jennifer
Sep 13 '09 #8
ADezii
8,834 Expert 8TB
Jennifer, download the Demo (Attachment) that I have now made available to you. With it you can Transpose any 1 of 3 Tables to a TAB Delimited/Quotes surrounding Strings, Text File. This File can then be easily Imported into Excel.
Attached Files
File Type: zip Transpose.zip (34.7 KB, 1019 views)
Sep 13 '09 #9
ADezii,
Thanks again for the code and example database. It works perfectly and beautifully in the example. I am in the process of implementing it in my database. I really appreciate all your help.
Take care,
Jennifer
Sep 20 '09 #10
ADezii
8,834 Expert 8TB
@jenniferhelen
Not a problem, Jennifer.
Sep 20 '09 #11
NeoPa
32,556 Expert Mod 16PB
@jenniferhelen
You're good Jennifer.

I do appreciate how difficult it is to express a question clearly enough to garner the right sort of response.

I'm happy you found ADezii for this anyway.
Sep 21 '09 #12
NeoPa
32,556 Expert Mod 16PB
Anyone interested in the hijack question inserted in here can now find it in a separate thread Transpose Table in Current Database.
Aug 7 '17 #13

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

Similar topics

1
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to use a make table query to pull the last transactionID, so I can use an append query to reset the transactionID to the next...
4
by: Oreo Bomb | last post by:
I have a secured database that contains a Read-Only group. This group has permissions to view reports, but cannot add, edit, or delete any DB objects. One of the reports the group needs access to...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
3
by: tdmailbox | last post by:
I set up my code to disable the shift bypass however for certain users I want to allow them through a button no a form to be able open up the list of tablies and queries. Is there a vb command...
2
by: Doc | last post by:
Per earlier post, I am trying to save 'out' production data from a program called Solomon - basically (I think) this was /is an Access/Sql based program. We are updating to different application...
1
by: danijela.simunovic | last post by:
Hi! Is there a way that when I run a "make table query" and an "append query" that i won't be asked those 2 or 3 questions from access like :"you are about to run a make table...","the existing...
4
by: ken | last post by:
Hi, I use this command to run a make table query without opening it... CurrentDb.Execute "make table query name" Access tells me that it can't execute a select query...? Its a make table query...
6
by: BrianDP | last post by:
I have a table that has always been in my back-end of this application. The table is getting quite large, and, on top of that, we lose records out of this table. They just dissappear! No rhyme or...
3
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which...
9
by: Mourad | last post by:
Hi All, Is it possible to create a Make Table query in access (2.0 and 2003) that creates the table into a SQL Server database? Following the steps: 1- Create New Query 2- Set Query Type as...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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?
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
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...

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.