zmbd 5,501
Expert Mod 4TB
So, I have the thread: Has Anyone Attempted a Report for a Class Attendance Log?
I've managed to get the format... however, I decided that I would like to append enough rows so that that there are a total of thirty rows - easy enough - problem with the sorting with the null records first, I can kludge that for now...
Then I thought, why not add teachers in to the mix, group the report on teachers and we're good to go - well not exactly - the first attempt resulted in a Roster page of blank rows followed by pages for each teacher without the blank rows (just student names). Of course, grouping by teachers in the report and I pulled a null field for the teachers:
(1st query) - SELECT [StudentList].[ID], [StudentList].[LastName]
-
, [StudentList].[FirstName], [t_teacher].[Teacher_Name]
-
, [t_teacher].[Teacher_Class]
-
FROM [t_teacher] INNER JOIN [StudentList]
-
ON [t_teacher].[PK_Teacher]
-
= [StudentList].[FK_Teacher]
-
ORDER BY [StudentList].[LastName]
-
UNION ALL SELECT [pk_blank], Null, Null, Null, Null
-
FROM [t_blank]
-
WHERE ([pk_blank] Between
-
((((SELECT Count(*)
-
FROM [StudentList]) - 1) Mod 30) + 2) And 30);
So my thought was cartesian product against the students table and the blank row table and pull the teacher name field in...
(this is version 5 :) ) - SELECT [StudentList].[ID], [StudentList].[LastName]
-
, [StudentList].[FirstName], [t_teacher].[Teacher_Name]
-
, [t_teacher].[Teacher_Class]
-
FROM [t_teacher] INNER JOIN [StudentList]
-
ON [t_teacher].[PK_Teacher]
-
= [StudentList].[FK_Teacher]
-
ORDER BY [StudentList].[LastName]
-
UNION SELECT [BRow], Null, Null, [Bname], Null
-
FROM
-
(SELECT [t_blank].[pk_blank] AS [BRow]
-
, [t_teacher].[Teacher_Name] AS [BName]
-
FROM [t_blank], [t_teacher]
-
INNER JOIN [StudentList]
-
ON [t_teacher].[PK_Teacher]
-
= [StudentList].[FK_Teacher]) AS Q1
-
WHERE ([BRow] Between
-
((((SELECT Count(*)
-
FROM [StudentList]) - 1) Mod 30) + 2) And 30);
I can get the sort right (as I said, it's a kludge method built a second query based on the union query with a calculated field that returns the last name if not null else "zzzz" and sorts on the calculated field); however, the appended rows are not following as expected. The First teacher will have the students followed by enough blanks to make up 25 rows and the next teacher will have a total of 16 rows the third teacher might have 9 rows total without any blanks.
What am I missing here?
Tables
[Students] (FK to [Teachers])
[Teachers] (FK to [Classes])
(each teacher teaches a single class for now :) )
2 891
I may seem like a copout, but I would create a Temp Table and build a VBA routine that fills out the Temp Table including blank rows where needed.
Unions are just not Access' strong point. Plus I think it will be easier to maintain/update, like when you get a teacher teaching multiple classes.
zmbd 5,501
Expert Mod 4TB
+ J, that may not be a copout on this situation.
However, I can set the union up to filter by teacher and then feed the report. TempVars work here very well for the source query and then VBA to drive the reports.
I was just hoping that there was a pure SQL approach to this as I have a few databases that I might be able to apply a similar concept for the reports. :(
+ Fortunately, there should not be a situation where a teacher has more than one class in a given year. However, just as a hobby, I'm building the entire thing out a bit more than I had originally intended. The database started out as a record source for a Word-Mailmerge document and I started thinking that I could combine the Workbook, Word Doc, and the database in to just the database - and the project has grown from there :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Xizor |
last post by:
Ok, what I want to do is find out the number of rows in a table. The most
obvious solution is to do something like the following:
$sql = "SELECT blah FROM blah WHERE 1";
$result =...
|
by: Egor Shipovalov |
last post by:
I'm implementing paging through search results using cursors. Is there a
better way to know total number of rows under a cursor than running a
separate COUNT(*) query? I think PostgreSQL is bound...
|
by: Aaron Smith |
last post by:
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way...
|
by: Melson |
last post by:
Hi
I've a problem. Can anyone help. I would like to use datagrid for data
entry. How can I set the number of rows in the datagrid. And use the
datagrid to update the ms sql table.
regards...
|
by: Gerhard |
last post by:
I would like a DataGrid I am using to show a default number of rows (10) with
the heading, even if the dataset it is bound to returns less than that number
of rows (0-9). It is a databound grid...
|
by: sysmanint1 |
last post by:
I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range.
Also, have never "posted" to a discussion
I have made a macro that works on...
|
by: muddasirmunir |
last post by:
I am using vb6 and crystal report 10 for making reports.
Now i am making a report , the report works fine just i want that the page number of the report start from the number which i give him.
...
|
by: premMS143 |
last post by:
Hi 1 & all,
Using VB,
How to remove blank rows in a Excel worksheet?
For example,
I'm having a Excel sheet containing 900 rows data, in which there are blank rows inserted in between. Manually...
|
by: mrubel99 |
last post by:
I am trying to come up with a formula that from a value say in A1, will count itself and the number of blank rows, which will vary between values and change on a daily basis, to the next value in...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |