Results 1 to 13 of 13
  1. #1
    Evilferret is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    27

    Continuous form with horizontal and vertical records

    I am building a continuous subform that needs to display records from a single table both horizontally and vertically.



    To illustrate my problem, my subform currently displays as follows:

    Record 1
    Record 2
    Record 3
    Record 4
    Record 5
    ...

    I would like it to display as follows:

    Record 1 Record 2 Record 3
    Record 3 Record 5 Record 6
    ...

    I know that I can use print preview to set the number of columns, however I am trying to modify the display of the form on the screen, rather than the display of the form on paper.

    Any assistance would be greatly appreciated.

  2. #2
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Not possible with standard Access features. Could be done with a lot - stress lot - of fiddly work that simulates (approximates) your requirement. Easier if the continuous form is read only.

  3. #3
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Not difficult for Display, If you want to do it

    Quote Originally Posted by Rod View Post
    Not possible with standard Access features. Could be done with a lot - stress lot - of fiddly work that simulates (approximates) your requirement. Easier if the continuous form is read only.
    Old question, but it seemed like an interesting little test of ingenuity. It can be done in two quick steps.

    Step 1 - Assuming you have 600 records, Use VBA to build a temporary table that consists of 200 records each with three foreign keys. Your choice whether to run them left-right or up-down. Let's call it tblThreeTempKey, and the three keys are FK1, FK2 and FK3. Leave extras NULL on the last record if needed.

    Step 2 - Let's assume your main table is tblStuff and its primary key is PK. Here's your query join (more or less)

    SELECT S1.*, S2.*, S3.*
    FROM (((tblThreeTempKey AS T3
    LEFT JOIN tblStuff AS S1 ON T3.FK1 = S1.PK)
    LEFT JOIN tblStuff AS S2 ON T3.FK2 = S2.PK)
    LEFT JOIN tblStuff AS S3 ON T3.FK3 = S3.PK)

    Now each single record returned by the query combines up to three different records from tblStuff, and you can make your 3-wide form based on the query.

    Not sure whether the query result will be updateable, though. It joins the same table three times, which tends to prevent updating, but each record in tblstuff will only appear once, so it might work.

  4. #4
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Would a Pivot table work?

    Dale

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Dal Jeanis View Post
    Step 1 - Assuming you have 600 records, Use VBA to build a temporary table that consists of 200 records each with three foreign keys. Your choice whether to run them left-right or up-down. Let's call it tblThreeTempKey, and the three keys are FK1, FK2 and FK3. Leave extras NULL on the last record if needed.

    Step 2 - Let's assume your main table is tblStuff and its primary key is PK. Here's your query join (more or less)

    SELECT S1.*, S2.*, S3.*
    FROM (((tblThreeTempKey AS T3
    LEFT JOIN tblStuff AS S1 ON T3.FK1 = S1.PK)
    LEFT JOIN tblStuff AS S2 ON T3.FK2 = S2.PK)
    LEFT JOIN tblStuff AS S3 ON T3.FK3 = S3.PK)

    Now each single record returned by the query combines up to three different records from tblStuff, and you can make your 3-wide form based on the query.

    Not sure whether the query result will be updateable, though. It joins the same table three times, which tends to prevent updating, but each record in tblstuff will only appear once, so it might work.
    As Rod said, "with a lot - stress lot - of fiddly work!"

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Dale - that's not what I think a pivot table does, but I could be wrong.

    Missinglinq - ...but, fiddly work is the fun part of this job! And I came up with two other methods last night that are a LOT more fiddly.


    By the way, if you add two blankish dummy records onto the end of the source file, then you can change the SQL to INNER JOINs.

  7. #7
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Thanks Dal.

    I have never used a pivot table. Just a guess.

    Dale

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Dal Jeanis View Post

    ...fiddly work is the fun part of this job...
    True, which is why I still play with this stuff years after everyone stopped paying me to do so!

    Have a great weekend!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Quote Originally Posted by Missinglinq View Post
    True, which is why I still play with this stuff years after everyone stopped paying me to do so!

    Linq ;0)>
    Likewise!

    The solution proposed by Dal Jeanis implies that you know the number of columns required which is not particularly elegant. Now think about a more general-purpose solution where you can change the number of columns on the fly.

  10. #10
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Elegance R Us

    ooo - a challenge.

    The main problem I see with a generalized solution is the display. It's trivial to have the VBA build the key table with an arbitrary number of horizontal keys - my mental code already assumed that strategy based on Recordsequencenumber Mod N with N=3, and the blank records at the bottom of the main file need to be N - 1 blank records.

    However, trying to link a fixed form to that arbitrary output isn't pretty. And I don't plan to rebuild a form on the fly, although it's technically possible if you don't like to sleep at night.

    Hmmm ... you also have to account for determining and dividing the available visual real estate ...

    I'd have to have some parameters for the problem I'm trying to "generally" solve, before I could take a swack at it. In other words, am I developing reusable code in anticipation of encountering similar problems in the future - in which case I'm basically there.

    Hmmm.

    Might be possible to develop a class object that provided multiple horizontal copies of a continuous form.

    Might also be possible to load one control (for example) with the types of the columns for each record, then a second control with an arbitrary number of columns of data. The form could then unpack those columns horizontally, enabling an arbitrary number of fields and buttons into each "cell". Modifying the data in a "cell" would cause the execution of an update against the file and a requery.

    Not something I'd do much work on without getting paid for it, though, and it's hard to imagine an application where this generalized solution is more proper than a well-defined interface based on an actual business use-case.

    This method is more like the Anderson Consulting method of mainframe consulting from the 1980s - write the client's CICS interface using a proprietary tool that is no better than COBOL, but that forces the client to continue using your services, because no one else can understand it. (Evil laugh.)

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @Dal

    WOW, you are twisted...... and I mean that in the nicest, best way.

    Reading your last post makes my head hurt!

  12. #12
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    @Dal

    Provided that the number of cells is not huge causing much virtual memory swapping then Access' OOP is probably the way to go. Maybe - and this is off the cuff - a cell class and a line class plus a collection of lines. The line class may well itself be a collection. What we're suggesting is a cut down (very cut down) version of word processing. Now how to get the OOP data onto the screen? Windows APIs may be the best answer; otherwise your thoughts re controls may be worth pursuing.

    On the other hand there's always Excel.

    @ssanfu
    Take two asprin and lie down until you feel strong again. Alternatively leave for the pub right now.

  13. #13
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    @Rod - Hmmm - and each cell could have an independent query for one recorrd, if you really want to give Jet hiccups!

    @Steve - the original Latin translation was slightly garbled, It was "I came; I saw; She conquered."

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

Similar Threads

  1. Horizontal to vertical data
    By hoachen in forum Access
    Replies: 3
    Last Post: 07-18-2012, 10:28 PM
  2. "transposing vertical data into horizontal columns"
    By stevelondon in forum Queries
    Replies: 3
    Last Post: 03-20-2012, 12:36 PM
  3. selecting all records on continuous form using vb
    By Mclaren in forum Programming
    Replies: 13
    Last Post: 01-03-2012, 12:20 PM
  4. Replies: 1
    Last Post: 01-28-2011, 02:45 PM
  5. Clear records off of continuous form
    By Ashe in forum Forms
    Replies: 2
    Last Post: 01-04-2011, 12:27 PM

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