Print when enough for one page

CanWest

Registered User.
Local time
Today, 05:34
Joined
Sep 15, 2006
Messages
272
Ok this one is a bit weird

My client wants to print a report when there is enough records to fill a page. Let me explain

There are two tables involved, a tbl_Clients and tbl_ContactNotes which is a sub of the clients table

Data entry takes place every time there is a conversation with a client. Some of these contact notes are very small, one or two sentences.

The want to save a tree or two so is there a way to determine when there is enough records to fill a page knowing that each one is a different length.

I hope this makes sense
 
Not having any idea of how to achieve it I hazard a stab in the dark anyway.

Would it be possible to test whether a report has more than one page?
If so, run the test after every entry and print out the report if there is more than one page.
You would need some way of hiding the new entry and then making it visible again while hiding all the old entries for the next entry.
 
Access does not know how many pages will be required until it formats the entire report. At that point, at best you will be able to tell how many pages there are but not in fractions of a page. Each section has an On Print event and within that you can capture the number of pages but you can't cancel the complete print job, just each sections content.

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
'Me.pages will tell you the total number of pages but you can't cancel the print, just this sections content
If Me.pages < 2 then Cancel = 1
End Sub

If you know the height of each row based on your font choice than you can count up how many characters and do the math and in the form that contains your button to print this report run some code and only generate the report if it equals a minimum number of characters.

Code:
Dim CharCount as Integer
Dim Rst as DAO.RecordSet
Dim MySql as String

CharCount = 0
'You need to decide what controls which records are included
MySql = "SELECT * FROM tbl_ContactNotes WHERE tbl_ContactNotes.ClientID = " & Me.ClientID;"
Set Rst = CurrentDb.OpenRecordset(MySql, dbOpenSnapShot)
Rst.MoveLast
Rst.MoveFirst
If Rst.RecordCount > 0 Then
     Do While Not Rst.EOF 
     CharCount = CharCount + Len(Rst!Notes)
     Rst.MoveNext
     Loop
End If
Rst.Close
Set Rst = Nothing
If CharCount > 500 Then 'you choose the size
Docmd.OpenReport "YourReport", acViewPreview
Else
Msgbox "Not enough for 1 page"
End If
 

Users who are viewing this thread

Back
Top Bottom