Results 1 to 4 of 4
  1. #1
    BatmanMR287 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    69

    Using Array to Display column horizontally instead of vertically

    I have a report that needs to display information from a column (eight members) horizontally.

    Ted Smith John Sampson Ricky Bobby

    Unfortunately access likes to display data in a column vertically.

    Ted Smith
    John Sampson


    Ricky Bobby

    Each person has a composite key for their group and for each individual. The individual number is an auto number.
    What I want to do is populate an array with the individual numbers and then be able to display each one at a time horizontally across the report as in the top example.
    This is a report that must be one button so setting a drop down box to select each one at a time is not an option.
    I need help writing the code.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would try to build a query that spit out the results I needed, vertically. Then I would use that query to populate controls in a Report. So probably, the query would be separate from the RecordSource of the report and the TextBox Controls would be Unbound.

    9 times out of 10 you will find a way to place the data into a table or use a query before there is a need for an Array. Here is an example of a multidimensional array the I keep in my notes for reference. It is not very intuitive but if you stare at the code it might start to make sense.
    Attached Files Attached Files

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    You want the names as column headers? What you want might be possible with CROSSTAB query. Otherwise, options:

    1. http://allenbrowne.com/func-concat.html

    2. https://www.accessforums.net/program...ias-21972.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,369
    Could you not use a crosstab query?
    Hope Y'all will forgive me if I repeat what's contained in the sample files, but I don't wish to download and set them up. I did check the links though, and think I method I learned is different. The AB version will concatenate the csv data into one field/control, n'est pas? The method I have in mind will take one field of data (rows) and spread each value across columns in a new query. Just so happens that for my case, the number was eight also. However, if that changes, you're looking at a fair bit of re-design. For my project, the array is also stored in a table as csv, and de-constructed when needed. The basics of the method are:
    - create a normal query to get the required data
    - open a recordset on this query, loop through, and build a csv array
    - create a function that will get the nth value from the array (Split function)
    - in another query, eight fields call the function as getWhatever(1), getWhatever(2), etc.
    An action such as form/report opening causes the code to start at the first step listed above and the output of the second query is the recordset for the form/report.

    Let me know if this sounds useful, but do check out the other suggestions posted first. It's a lot of work.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-17-2013, 09:20 PM
  2. Replies: 2
    Last Post: 01-08-2013, 04:59 PM
  3. Replies: 7
    Last Post: 10-18-2012, 12:49 PM
  4. Replies: 4
    Last Post: 05-25-2012, 09:43 AM
  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