By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,583 Members | 3,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,583 IT Pros & Developers. It's quick & easy.

Displaying two records on one row of a form

P: n/a
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.
Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
> 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.


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

Nov 12 '05 #2

P: n/a
"Matt K." wrote:
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.


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.
Nov 12 '05 #3

P: n/a
Salad <oi*@vinegar.com> wrote in message news:<3F**************@vinegar.com>...

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.


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
Nov 12 '05 #4

P: n/a
DFS

"Matt K." <ma*******@yahoo.com> wrote in message
news:65**************************@posting.google.c om...
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!


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.


Nov 12 '05 #5

P: n/a
ma*******@yahoo.com (Matt K.) wrote in
news:65**************************@posting.google.c om:
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!


SELECT SubQuery.fldTransactionID,
First(SubQuery.Date1) AS Date1,
First(SubQuery.Date2) AS Date2
FROM
[SELECT t1.fldTransactionID,
t1.fldDate AS Date1,
t2.fldDate AS Date2
FROM tbl2002Transactions AS t1
LEFT JOIN tbl2002Transactions AS t2
ON t2.fldTransactionID > t1.fldTransactionID]. SubQuery
WHERE Filter(fldTransactionID)<>0
GROUP BY SubQuery.fldTransactionID

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)
Nov 12 '05 #6

P: n/a
Lyle Fairfield <Mi************@Invalid.Com> wrote in
news:Xn*******************@130.133.1.4:
ma*******@yahoo.com (Matt K.) wrote in
news:65**************************@posting.google.c om:
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!


SELECT SubQuery.fldTransactionID,
First(SubQuery.Date1) AS Date1,
First(SubQuery.Date2) AS Date2
FROM
[SELECT t1.fldTransactionID,
t1.fldDate AS Date1,
t2.fldDate AS Date2
FROM tbl2002Transactions AS t1
LEFT JOIN tbl2002Transactions AS t2
ON t2.fldTransactionID > t1.fldTransactionID]. SubQuery
WHERE Filter(fldTransactionID)<>0
GROUP BY SubQuery.fldTransactionID

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.


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.fldTransactionID,"
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.fldTransactionID,"
sql = sql & vbNewLine
sql = sql & "t1.fldDate AS Date1,"
sql = sql & vbNewLine
sql = sql & "t2.fldDate AS Date2"
sql = sql & vbNewLine
sql = sql & "FROM tbl2002Transactions AS t1"
sql = sql & vbNewLine
sql = sql & "LEFT JOIN tbl2002Transactions AS t2"
sql = sql & vbNewLine
sql = sql & "ON t2.fldTransactionID > t1.fldTransactionID]. SubQuery"
sql = sql & vbNewLine
sql = sql & "WHERE Filter(fldTransactionID) <> 0"
sql = sql & vbNewLine
sql = sql & "GROUP BY SubQuery.fldTransactionID"
CurrentProject.Connection.Execute "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)
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.