You'd think that something like this would be so easily available on the net - and yet, it's not.
Do a search here on bytes and this same topic turns up over and over; however, with some surprisingly different solutions.
In one, VBA is used to draw the lines in based on the record count.
SO what Prompted my little walk thru fire today: A "problem" popped up where in we used to have 25 rows on a pre-printed that used to have the "template" grid and text pre-printed in the details section is now blank - cheaper I'm sure. However, without these extra rows, the sprawl all over the page looks, well, not so professional.
I'm thinking... HEY, we just solved this problem like just last week - whewho-and-fist-pump!
Find the thread: 946504-adding-empty-records
Made the 25 row table ([ID]={1,2,3,...24,25}), altered the SQL we have here... and it works like a dream for the 25 row pre-printed document.
YEA!
Now, thinking "green" (I know... thinking again) we have these 3 x 1 - Row labels on an 8-1/2x11 paper that I'm constantly having one or two blank labels that go to waste because we'll only print what is in the database que. These unprinted labels go to waste as they can only go thru the thermal printer once.
And when we need a few "blank" labels for those one off hand entries, we have a word document to print a few blank forms. (back to that green thing) I'm like, hey, just use that ole-add the blank record to the end and we're no longer wasting the label and we shouldn’t ever need to “hand” print the extras again!
(OK, NeoPa and Rabbit: get out your girdles, you'll have a chuckle with this)
So, tweak the 25 to 3 in the SQL and What Worked wonderfully for the 25 row... wouldn't work for the 3 per page.
.... puzzled expression ....
Extra labels, or not enough labels and so forth... it didn't help that I've three other people and instruments wanting my attention for other projects too! Print Preview is a wonderful thing!
So after a day of interruptions and doing the math, wouldn't have taken so long if I could have just worked out the math in peace, I finally hit on the solution to make another table with only three blank rows for the 3 per page - and that worked!
However, I don't want two tables with blank records out there and possibly yet a third or fourth depending on customer and lab needs... so what to do?
My final solution has to deal with how the [ID] field is numbered in tbl_blank.
I have a set of [ID]={3001,3002,3003}; [ID]={25001,25002,25003,...25024,25025}]
So if I needed 100 rows... {100001, 100002,...100100}
SO using the code block from the above thread that solved the 15 row issue:
Expand|Select|Wrap|Line Numbers
- SELECT Null AS [IDField]
- , *
- FROM [tblEvidence]
- UNION ALL
- SELECT [IDField]
- , Null
- , Null
- , ... etc
- FROM [tblBlank]
- WHERE ([IDField] Between ((((SELECT Count(*)
- FROM [tblEvidence]) - 1) Mod 15) + 2) And 15)
We modify as needed to use those [ID] ranges thus:
Expand|Select|Wrap|Line Numbers
- (first part of SQL omitted)
- (for the 3x3):
- UNION ALL
- SELECT [blank_pk] as F1,
- "",
- ""
- FROM [tbl_Blank]
- WHERE ([blank_pk] Between
- ((((SELECT Count(*)
- FROM [tbl_data]) - 1) Mod 3) + 3002) And 3003)
- (for the 25 row form:)
- (first part omited...)
- FROM [tbl_data]) - 1) Mod 25) + 25002) And 25025)
-z