Results 1 to 14 of 14
  1. #1
    titiakila is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    22

    Display a table horizontally in a form

    Hello,


    I would like to know how to display a table horizontally in a form in ACCESS.


    For example I have the table :


    product price brand
    coca-cola 3,0 coca
    pepsi-cola 2,5 pepsi
    orangina 3,0 -


    and I would like to display


    product coca-cola pepsi-cola orangina
    price 3,0 2,5 3,0
    brand coca pepsi -


    with the names of the fields in a column


    Thanks

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,205
    Create a crosstab query and use that as your form's record source
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    titiakila is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    22
    Thank you. Yes but what would be the query ?

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,823
    Hi
    Can you upload a zipped copy of the database?

  5. #5
    titiakila is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    22
    No I'm sorry I can't.
    It's was just a test database to do it on a bigger.
    The names of columns are in the first line.

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,159
    Open the query designer. Add your table.
    Right Click the section above the grid and Select Query Type - "CrossTab"

    Add Product to the Grid, in the crosstab section select Column heading.
    Add Price to the Grid and select Value as the Crosstab selection
    Add Brand and select Row Heading as the cross tab selection

    It won't be exactly want you want, but you'll see how it works.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,205
    Actually re-reading your question, I don't think you can get exactly what you want in any recent version of Access.
    You can use the crosstab query wizard to get something similar. Use your own table name instead of Table1

    Code:
    TRANSFORM First(Table1.[Price]) AS FirstOfPrice
    SELECT Table1.[Brand]
    FROM Table1
    GROUP BY Table1.[Brand]
    ORDER BY Table1.[Brand] DESC 
    PIVOT Table1.[Product];
    You may be able to modify that to approximately suit your needs
    However, the easiest solution would be to do this in Excel using Transpose Data.

    Good luck
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  8. #8
    titiakila is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    22
    effectively a crosstab query is not exactly what I am looking for because you have to chose columns to the left and one unique field of values and I want to have the name of the fields to the left so that is not exactly that. Oh ok maybe there is no solution with access. Thank you all very much for your help.

  9. #9
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,205
    Its trivial to do in Excel:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	16 
Size:	17.0 KB 
ID:	45666
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  10. #10
    titiakila is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    22
    Yes I know but I wanted to do that on access because that is there I do my interface on the database not in Excel. Thank you for your response.

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,205
    In that case, it looks like you're out of luck.
    Its not how Access is designed to work.

    Obviously you could paste the transposed data back into Access or open the Excel file within Access using a web browser control as shown below
    For info the Excel file is fully editable in a web browser control

    Click image for larger version. 

Name:	Capture2.PNG 
Views:	15 
Size:	40.0 KB 
ID:	45667
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,159
    You could (if you really have to) achieve this in VBA, but it's a lot of work.
    Sometimes it's better to get people (end users) to accept the different presentation and get used to it, rather than having to jump through a lot of hoops trying to make it look and behave the same as excel.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    titiakila is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    22
    Thank you very much. I will consider both options. You're right maybe it's better to leave the columns vertically and just convince the users.

  14. #14
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    If you want to make the effort, see these links

    https://access-4suc6.blogspot.com/20...umns-into.html

    or google 'access vba transpose columns to rows' or similar for other links

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Display images horizontally
    By ezybusy in forum Forms
    Replies: 5
    Last Post: 06-01-2017, 11:24 AM
  2. Display report items horizontally?
    By dmon2010 in forum Reports
    Replies: 1
    Last Post: 04-07-2016, 12:02 PM
  3. Display vertical info horizontally
    By dpill in forum Queries
    Replies: 4
    Last Post: 03-18-2016, 03:06 PM
  4. Replies: 11
    Last Post: 11-04-2015, 12:41 PM
  5. Replies: 11
    Last Post: 10-04-2011, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums