Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Blank LInes to a Report

Status
Not open for further replies.

whjwilson

Technical User
Jan 20, 2006
23
US
I am working on a report that will print out the Army hand recipt (DA Form 2062). The form itselt can consist of one page or multiple pages. The first page of the form has room for 16 lines of data, and each page after has room for 21 lines of data. In order for the form to be deemed "legal" for use, it has to be the whole form. So I will need the report to print with blanks lines of data based upon the number of items input by the user.

For instance if X:

16 > X add N blank records to equal 16

16 < X < 37 add N blank records to equal 37
37 < X < 58 add N blank records to equal 58
58 < X < 79 add N blank records to equal 79

so on and so forth.
My report is being populated from a table call OC. The table has two columns Equipment and Item.

I was provided the following code to use by MajP but cannot seem to get it to work and think I may be doing something wrong:


Code:
Public Function getnumberofBlanks() As Integer
  Dim recordCount As Integer
  Dim N As Integer
  recordCount = DCount("*", Me.OC)
  If recordCount <= 16 Then
    getnumberofBlanks = 16 - recordCount
  Else
    N = 1
    Do while N * 21 + 16 <= recordCount
      N = N + 1
    Loop
    getnumberofBlanks = (N * 21 + 16) - recordCount
  End If
End Function

Public Sub printBlankRecords(numberBlanks As Integer)
  Dim recordCount As Integer
  recordCount = DCount("*", Me.OC)
  TotalCount = TotalCount + 1
  
  If TotalCount = recordCount Then
    Me.NextRecord = False
    'once you get to the last record, stay on last record
  ElseIf TotalCount > recordCount And TotalCount < (recordCount + numberBlanks) Then
    Me.NextRecord = False
    'make the font and backcolor the same appearing to be empty record
    Me.Equipment.ForeColor = Me.Equipment.BackColor
    Me.Item.ForeColor = Me.Item.BackColor
  End If
End Sub Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  printBlankRecords getnumberofBlanks
End Sub

The code does not add any blank lines to the report when printed. I just can't figure it out. Should I be using a Query instead of the table to populated my form?
 
Seems like TotalCount should be defined outside any procedure as Public.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That is correct it is a public variable. I think I forgot to paste that in.
If you start a related thread you can reference it by type the word "Thread" followed directly by the number. That way everyone has the background.
Thread702-1683569
Also I have played more with the code with a slight twist
Thread705-1695691

Any chance you can post your database on a file sharing site with some limited real data? I would be interested in trying to populate the Access report and Word version with representative data.
 
I put the solutions in Thread702-1683569 since they directly relate to Form DA2062.
 
an alternative approacch (no coded) w2ould be to usw the page number and use the page recoed count to invoke the page footer. No (blank) lines necessary.

MichaelRed


 
MR said:
an alternative approacch (no coded) w2ould be to usw the page number and use the page recoed count to invoke the page footer. No (blank) lines necessary

Any chance you can explain that? Have no idea what that means.
 
Although posted in FORMS. tthe request mentions REPORTS.

MS Access reports include the capability of having "Page N of M" tp reports.

Each page would include a page header (presumably this could / would include the page n of m) and hide a footer with a page break.

Page 1 would simply count 16 rcords, then unhide the footer with a page break

subsquent pages would count 21 records before unhiding the footer.

some details missing, but my eyesignht is no longer sufficient for me to read what i type, so these fundamentals and access to the ubiquitous help facility shoub be sufficient.




MichaelRed


 
@MichaelRed
Can you explain how that would print a variable amount of blank records? You can look at the solutions I provided. See post 23 Oct 11:32. If you can do this using a footer and no code then I would be interested, I am highly skeptical.
 
There is no need to print blank lines.


Count the real record lines per the page number ("N" from Page N of M)

When the necessary number is reached, cause the process to unhide a page break symbol (hoperfully in the page footer?) and stop printing the 'section' (presumably the detail?).

The remainder of the page should print (including the page footer).

In the page header of ALL pages, hide the page break.

Repeat as necessary



MichaelRed


 
There is no need to print blank lines
You must have read the post wrong. That is the whole point of the thread. The OP is not trying to force a page break after a set amount of lines, the OP is trying to mimic a government form. The first page of the form has 16 rows. If only 8 rows have data it would need to show 8 with data and 8 blank rows. On the second page there is 21 rows. So if the use has 30 rows of data they would need seven blank rows on the second page. I do not think what you are suggesting is relevant to this post.
 
MajP, using the code provided above, I've been able to get the blank lines in the 2062 to show in print preview, but when I actually print the report, only the original records print, and they print with white font (like the blank lines). What did I do wrong?
 
That is probably a problem that I could not help without seeing the actual database. My guess is that it has nothing to do with my code, but with the formatting on your form. Here is a working database with two solutions.


One solution uses the print method to print a X amount of empty records. The other uses a table of blank records. Figures out how many are needed and unions those blank records.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top