473,414 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Appending Consistent Number of Blank Rows to Report

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)
Expand|Select|Wrap|Line Numbers
  1. SELECT [StudentList].[ID], [StudentList].[LastName]
  2.    , [StudentList].[FirstName], [t_teacher].[Teacher_Name]
  3.    , [t_teacher].[Teacher_Class]
  4. FROM [t_teacher] INNER JOIN [StudentList] 
  5.       ON [t_teacher].[PK_Teacher] 
  6.          = [StudentList].[FK_Teacher]
  7. ORDER BY [StudentList].[LastName]
  8. UNION ALL SELECT [pk_blank], Null, Null, Null, Null
  9. FROM [t_blank]
  10. WHERE ([pk_blank] Between
  11.        ((((SELECT Count(*)
  12.            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 :) )
Expand|Select|Wrap|Line Numbers
  1. SELECT [StudentList].[ID], [StudentList].[LastName]
  2.    , [StudentList].[FirstName], [t_teacher].[Teacher_Name]
  3.    , [t_teacher].[Teacher_Class]
  4. FROM [t_teacher] INNER JOIN [StudentList] 
  5.       ON [t_teacher].[PK_Teacher] 
  6.          = [StudentList].[FK_Teacher]
  7. ORDER BY [StudentList].[LastName]
  8. UNION SELECT [BRow], Null, Null, [Bname], Null
  9. FROM 
  10.    (SELECT [t_blank].[pk_blank] AS [BRow]
  11.    , [t_teacher].[Teacher_Name] AS [BName]
  12.    FROM [t_blank], [t_teacher] 
  13.       INNER JOIN [StudentList] 
  14.          ON [t_teacher].[PK_Teacher] 
  15.             = [StudentList].[FK_Teacher]) AS Q1
  16. WHERE ([BRow] Between
  17.        ((((SELECT Count(*)
  18.            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 :) )
Aug 31 '16 #1
2 891
jforbes
1,107 Expert 1GB
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.
Sep 1 '16 #2
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 :)
Sep 1 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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 =...
7
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...
10
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...
4
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...
3
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...
0
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...
3
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. ...
1
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...
2
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.