Displaying two records on one row of a form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt K.

    Displaying two records on one row of a form

    Hi there,

    I have a form in an Access project that contains a subform which
    displays the results of a query of the style "select * from [table]
    where [datefield] = #a certain date#". In the main part of the form
    the user can change the date, which will force a requery in the
    subform to bring up records from the date selected.

    My question is this... The query in the subform is a very simple one,
    with only three fields being returned. In the interest of saving
    space -- or rather, of displaying more records on-screen in the
    subform without the user having to scroll -- I'd like to show two
    records across one row of the subform.

    That is, I'd like the subform to have 6 columns instead of 3, with two
    "groups" of 3 columns so two records can be displayed in one row.
    However, I'm not sure if this is possible -- if I set up the subform
    to have two "RecDate" fields, and two of each of the other fields, I
    obviously just get the same record repeated twice across the row.

    It's not crucial as it's an esthetic thing and not a functional one,
    but if there's a simple way to do this I'd love to know how... any
    suggestions are appreciated!

    Thanks!

    Matt K.
  • Arno R

    #2
    Re: Displaying two records on one row of a form

    > That is, I'd like the subform to have 6 columns instead of 3, with two[color=blue]
    > "groups" of 3 columns so two records can be displayed in one row.
    > However, I'm not sure if this is possible -- if I set up the subform
    > to have two "RecDate" fields, and two of each of the other fields, I
    > obviously just get the same record repeated twice across the row.[/color]

    Matt,
    AFAIK this is not possible.
    -- Perhaps you could use two subforms ?
    -- Perhaps it is possible to place your subform to the left or the right of your mainform?

    --
    Hope this helps
    Arno R



    Comment

    • Salad

      #3
      Re: Displaying two records on one row of a form

      "Matt K." wrote:
      [color=blue]
      > Hi there,
      >
      > I have a form in an Access project that contains a subform which
      > displays the results of a query of the style "select * from [table]
      > where [datefield] = #a certain date#". In the main part of the form
      > the user can change the date, which will force a requery in the
      > subform to bring up records from the date selected.
      >
      > My question is this... The query in the subform is a very simple one,
      > with only three fields being returned. In the interest of saving
      > space -- or rather, of displaying more records on-screen in the
      > subform without the user having to scroll -- I'd like to show two
      > records across one row of the subform.
      >
      > That is, I'd like the subform to have 6 columns instead of 3, with two
      > "groups" of 3 columns so two records can be displayed in one row.
      > However, I'm not sure if this is possible -- if I set up the subform
      > to have two "RecDate" fields, and two of each of the other fields, I
      > obviously just get the same record repeated twice across the row.
      >
      > It's not crucial as it's an esthetic thing and not a functional one,
      > but if there's a simple way to do this I'd love to know how... any
      > suggestions are appreciated!
      >
      > Thanks!
      >
      > Matt K.[/color]

      Sure you can. With a good bit of skull sweat you can do most anything
      database related in Access. And I doubt you'd find a single person in
      this group that would want to do what you propose.
      Adding/editting/deleting records would be a chore. The result would be an
      ugly kludge. You would need to be a VBA guru to do it. And you'd waste
      time designing and writing your kludge and then your work would suffer and
      you'd be unproductive and your bosses would notice it and lay you off and
      you'd be unemployed and you would sit at home dialing new employers while
      wondering why you ever decided to put two records on one row.


      Comment

      • Matt K.

        #4
        Re: Displaying two records on one row of a form

        Salad <oil@vinegar.co m> wrote in message news:<3FF5A7E3. 9F9E52D@vinegar .com>...[color=blue]
        >
        > Sure you can. With a good bit of skull sweat you can do most anything
        > database related in Access. And I doubt you'd find a single person in
        > this group that would want to do what you propose.
        > Adding/editting/deleting records would be a chore. The result would be an
        > ugly kludge. You would need to be a VBA guru to do it. And you'd waste
        > time designing and writing your kludge and then your work would suffer and
        > you'd be unproductive and your bosses would notice it and lay you off and
        > you'd be unemployed and you would sit at home dialing new employers while
        > wondering why you ever decided to put two records on one row.[/color]

        Thanks (to Arno as well) for the quick replies, much appreciated!

        I figured based on my level of Access knowledge -- fairly experienced
        user, but not "formally" trained -- that what I had in mind was either
        impossible (or so complicated as to be effectively impossible) or
        something obvious that I'd overlooked.

        By posting the question I was to trying to ensure it wasn't the
        latter. :)

        Thanks again, and Happy New Year!

        --Matt

        Comment

        • DFS

          #5
          Re: Displaying two records on one row of a form


          "Matt K." <mattk9999@yaho o.com> wrote in message
          news:65cc286a.0 401020802.146ff 97b@posting.goo gle.com...[color=blue]
          > Hi there,
          >
          > I have a form in an Access project that contains a subform which
          > displays the results of a query of the style "select * from [table]
          > where [datefield] = #a certain date#". In the main part of the form
          > the user can change the date, which will force a requery in the
          > subform to bring up records from the date selected.
          >
          > My question is this... The query in the subform is a very simple one,
          > with only three fields being returned. In the interest of saving
          > space -- or rather, of displaying more records on-screen in the
          > subform without the user having to scroll -- I'd like to show two
          > records across one row of the subform.
          >
          > That is, I'd like the subform to have 6 columns instead of 3, with two
          > "groups" of 3 columns so two records can be displayed in one row.
          > However, I'm not sure if this is possible -- if I set up the subform
          > to have two "RecDate" fields, and two of each of the other fields, I
          > obviously just get the same record repeated twice across the row.
          >
          > It's not crucial as it's an esthetic thing and not a functional one,
          > but if there's a simple way to do this I'd love to know how... any
          > suggestions are appreciated![/color]

          Simple to do, but kind of unusual and not recommended. Instead, do a Top 2
          query and show two records as they appear in the table: 2 rows of 3 columns
          each.

          If you want to try the 2-on-1-row thing, this is one way (assumes you don't
          know how many records will match your #certain date# value):

          1) create a query to get the Top 1 record matching your #certain date#
          2) create another query getting the Top 2 records matching the #certain
          date#, and not matching the Top 1 (ie if there are at least two matching
          records, this query will return one record)
          3) create a third query combining all the fields from the first two queries
          (do a left join from query 1 to query 2, on the #certain date# field, in
          case query 2 doesn't return anything)
          4) base your subform on the third query

          You might add a blank field between the groups of 3 fields, to help indicate
          visually the separate records.




          Comment

          • Lyle Fairfield

            #6
            Re: Displaying two records on one row of a form

            mattk9999@yahoo .com (Matt K.) wrote in
            news:65cc286a.0 401020802.146ff 97b@posting.goo gle.com:
            [color=blue]
            > Hi there,
            >
            > I have a form in an Access project that contains a subform which
            > displays the results of a query of the style "select * from [table]
            > where [datefield] = #a certain date#". In the main part of the form
            > the user can change the date, which will force a requery in the
            > subform to bring up records from the date selected.
            >
            > My question is this... The query in the subform is a very simple one,
            > with only three fields being returned. In the interest of saving
            > space -- or rather, of displaying more records on-screen in the
            > subform without the user having to scroll -- I'd like to show two
            > records across one row of the subform.
            >
            > That is, I'd like the subform to have 6 columns instead of 3, with two
            > "groups" of 3 columns so two records can be displayed in one row.
            > However, I'm not sure if this is possible -- if I set up the subform
            > to have two "RecDate" fields, and two of each of the other fields, I
            > obviously just get the same record repeated twice across the row.
            >
            > It's not crucial as it's an esthetic thing and not a functional one,
            > but if there's a simple way to do this I'd love to know how... any
            > suggestions are appreciated![/color]

            SELECT SubQuery.fldTra nsactionID,
            First(SubQuery. Date1) AS Date1,
            First(SubQuery. Date2) AS Date2
            FROM
            [SELECT t1.fldTransacti onID,
            t1.fldDate AS Date1,
            t2.fldDate AS Date2
            FROM tbl2002Transact ions AS t1
            LEFT JOIN tbl2002Transact ions AS t2
            ON t2.fldTransacti onID > t1.fldTransacti onID]. SubQuery
            WHERE Filter(fldTrans actionID)<>0
            GROUP BY SubQuery.fldTra nsactionID

            Public Function Filter(ByVal vID As Long)
            Static ID As Long
            Static Counter As Long
            If ID > vID Then Counter = 0
            ID = vID
            Counter = Counter + 1
            Filter = Counter Mod 2
            End Function

            This shows Date1 from first record), Date2 (from second record)
            Date3, Date4
            Date5, Date6
            etc.

            It's interesting as a Sunday morning recreation, but I can't imagine ever
            using it.

            If you should decide to try to use this, please note that the syntax of the
            Subquery, including the initial "[" and the closing closing "] dot space
            alias" is required. If you don't like [ and ], you may use ` instead, I
            believe.


            --
            Lyle
            (for e-mail refer to http://ffdba.com/contacts.htm)

            Comment

            • Lyle Fairfield

              #7
              Re: Displaying two records on one row of a form

              Lyle Fairfield <MissingAddress @Invalid.Com> wrote in
              news:Xns9465505 7864EFFFDBA@130 .133.1.4:
              [color=blue]
              > mattk9999@yahoo .com (Matt K.) wrote in
              > news:65cc286a.0 401020802.146ff 97b@posting.goo gle.com:
              >[color=green]
              >> Hi there,
              >>
              >> I have a form in an Access project that contains a subform which
              >> displays the results of a query of the style "select * from [table]
              >> where [datefield] = #a certain date#". In the main part of the form
              >> the user can change the date, which will force a requery in the
              >> subform to bring up records from the date selected.
              >>
              >> My question is this... The query in the subform is a very simple one,
              >> with only three fields being returned. In the interest of saving
              >> space -- or rather, of displaying more records on-screen in the
              >> subform without the user having to scroll -- I'd like to show two
              >> records across one row of the subform.
              >>
              >> That is, I'd like the subform to have 6 columns instead of 3, with two
              >> "groups" of 3 columns so two records can be displayed in one row.
              >> However, I'm not sure if this is possible -- if I set up the subform
              >> to have two "RecDate" fields, and two of each of the other fields, I
              >> obviously just get the same record repeated twice across the row.
              >>
              >> It's not crucial as it's an esthetic thing and not a functional one,
              >> but if there's a simple way to do this I'd love to know how... any
              >> suggestions are appreciated![/color]
              >
              > SELECT SubQuery.fldTra nsactionID,
              > First(SubQuery. Date1) AS Date1,
              > First(SubQuery. Date2) AS Date2
              > FROM
              > [SELECT t1.fldTransacti onID,
              > t1.fldDate AS Date1,
              > t2.fldDate AS Date2
              > FROM tbl2002Transact ions AS t1
              > LEFT JOIN tbl2002Transact ions AS t2
              > ON t2.fldTransacti onID > t1.fldTransacti onID]. SubQuery
              > WHERE Filter(fldTrans actionID)<>0
              > GROUP BY SubQuery.fldTra nsactionID
              >
              > Public Function Filter(ByVal vID As Long)
              > Static ID As Long
              > Static Counter As Long
              > If ID > vID Then Counter = 0
              > ID = vID
              > Counter = Counter + 1
              > Filter = Counter Mod 2
              > End Function
              >
              > This shows Date1 from first record), Date2 (from second record)
              > Date3, Date4
              > Date5, Date6
              > etc.
              >
              > It's interesting as a Sunday morning recreation, but I can't imagine
              > ever using it.
              >
              > If you should decide to try to use this, please note that the syntax of
              > the Subquery, including the initial "[" and the closing closing "] dot
              > space alias" is required. If you don't like [ and ], you may use `
              > instead, I believe.[/color]

              OOPS /// while this query will run without any problems on my machine, it
              will not save from the query wizard window. Access crashes.

              It will, however save thus:

              Sub temp()
              Dim sql As String
              sql = sql & "SELECT SubQuery.fldTra nsactionID,"
              sql = sql & vbNewLine
              sql = sql & "First(SubQuery .Date1) AS Date1,"
              sql = sql & vbNewLine
              sql = sql & "First(SubQuery .Date2) As Date2"
              sql = sql & vbNewLine
              sql = sql & "FROM"
              sql = sql & vbNewLine
              sql = sql & "[SELECT t1.fldTransacti onID,"
              sql = sql & vbNewLine
              sql = sql & "t1.fldDate AS Date1,"
              sql = sql & vbNewLine
              sql = sql & "t2.fldDate AS Date2"
              sql = sql & vbNewLine
              sql = sql & "FROM tbl2002Transact ions AS t1"
              sql = sql & vbNewLine
              sql = sql & "LEFT JOIN tbl2002Transact ions AS t2"
              sql = sql & vbNewLine
              sql = sql & "ON t2.fldTransacti onID > t1.fldTransacti onID]. SubQuery"
              sql = sql & vbNewLine
              sql = sql & "WHERE Filter(fldTrans actionID) <> 0"
              sql = sql & vbNewLine
              sql = sql & "GROUP BY SubQuery.fldTra nsactionID"
              CurrentProject. Connection.Exec ute "CREATE PROCEDURE Query6 AS " & sql
              End Sub

              It runs fine, but cannot be saved from the query wizard sql window.

              Didn't try saving it with DAO, but it is saved properly using ADO as above.

              --
              Lyle
              (for e-mail refer to http://ffdba.com/contacts.htm)

              Comment

              Working...