harleyskater
IT Manager
- Local time
- Today, 12:41
- Joined
- Oct 29, 2007
- Messages
- 95
Code won't work correctly only with the numbers greater than 7
I would also like to add if I change the max number of rows "ctotalrows" to 7, it still prints the last record, on a seperate page.
"attached 4 pictures through zipfile and code to post"
The pictures explain the problem much better then my description ; )
Ok so I got this vba code from a code library and I have been using it/minipulating it to use with a lot of my reports to fill in blank space and make it look professional. Works great for a report that doesn't really report anything just prints things like purchase orders and quotes and things that basically will have sometimes 1 item or sometimes 20 items. (fills in the blank space left by a page that only holds 1 item ie. you only purchased 1 item) It works great until the total amount of records in the details section is 7 or greater. I will attach 2 pictures and the code and if someone needs a sample db. I just want to know if there is a fix for this. It doesn't do anything but print an extra record.
Just a quick explaination on the code. There is a field in the header called TotGrp that is set to Count(*). There is also a procedure listed below that is called as an on print event that sets the forecolor = 0.
There is a second print event called from the details section that increments lngCount + 1 keeping track of the number of times the procedure is called, then there is another constantant "cTotalRows" that is set to 8 for the max number of records to be printed on one page. When the lngCount gets to the total number of records in the details section it repeats the last record but makes the foreground color white so it appears blank on the printed page with a gridline around it to fill in the space left blank of the page as long as longCount is less then the max rows constant cTotalrows and you have exceeded your count from totgrp - the number of records in the details section.
I am completely confused by this hahaha I have played around with it for a day now getting nowhere fast. If anyone can figure this out hahah I will be super duper happy
!
I would also like to add if I change the max number of rows "ctotalrows" to 7, it still prints the last record, on a seperate page.
"attached 4 pictures through zipfile and code to post"
The pictures explain the problem much better then my description ; )
Ok so I got this vba code from a code library and I have been using it/minipulating it to use with a lot of my reports to fill in blank space and make it look professional. Works great for a report that doesn't really report anything just prints things like purchase orders and quotes and things that basically will have sometimes 1 item or sometimes 20 items. (fills in the blank space left by a page that only holds 1 item ie. you only purchased 1 item) It works great until the total amount of records in the details section is 7 or greater. I will attach 2 pictures and the code and if someone needs a sample db. I just want to know if there is a fix for this. It doesn't do anything but print an extra record.
Just a quick explaination on the code. There is a field in the header called TotGrp that is set to Count(*). There is also a procedure listed below that is called as an on print event that sets the forecolor = 0.
There is a second print event called from the details section that increments lngCount + 1 keeping track of the number of times the procedure is called, then there is another constantant "cTotalRows" that is set to 8 for the max number of records to be printed on one page. When the lngCount gets to the total number of records in the details section it repeats the last record but makes the foreground color white so it appears blank on the printed page with a gridline around it to fill in the space left blank of the page as long as longCount is less then the max rows constant cTotalrows and you have exceeded your count from totgrp - the number of records in the details section.
Code:
Option Compare Database
Option Explicit
Const cTotalRows = 8 'the desired total number of rows in this instance
Const stdHeight = 240
Dim lngCount As Long
Dim lngTotal As Long
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
lngCount = lngCount + 1
If lngCount = TotGrp Then
Me.NextRecord = False
ElseIf lngCount > TotGrp And lngCount < cTotalRows Then
Me.NextRecord = False
Me![operation_id].ForeColor = 16777215
Me![operation_num].ForeColor = 16777215
Me![op_type].ForeColor = 16777215
Me![op_description].ForeColor = 16777215
Me![emp_id].ForeColor = 16777215
Me![insp_date].ForeColor = 16777215
Me![insp_by].ForeColor = 16777215
End If
End Sub
Private Sub GroupHeader1_Print(Cancel As Integer, PrintCount As Integer)
lngCount = 0
Me![operation_id].ForeColor = 0
Me![operation_num].ForeColor = 0
Me![op_type].ForeColor = 0
Me![op_description].ForeColor = 0
Me![emp_id].ForeColor = 0
Me![insp_date].ForeColor = 0
Me![insp_by].ForeColor = 0
End Sub
I am completely confused by this hahaha I have played around with it for a day now getting nowhere fast. If anyone can figure this out hahah I will be super duper happy
Attachments
Last edited: