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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining the page range of a group

Status
Not open for further replies.

Phil5673

Programmer
Sep 30, 2002
42
US
Is there a way to determine the page range of a group. For example, determine what page Customer X begins on and what page Customer X ends on. I want to do this so I can send these pages to the DoCmd.Printout. Currently I am opening the report with a filter option. This reruns the query that the report is based on. I am trying to avoid this as it takes up a substantial amount of time.

Thanks for any help.

Phil Edwards
 
It would take a lot of work. You would need to measure your margins, headers and footers. Then the space left for the detail. Then the font size, and how much is taken up per line of detail. Then multiple a query for records. 50 records = x" ->2 pages

then run a check on that to give yourself the answer.
Have fun with that!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
re run the query with =customerx in the criteria field it's easier.


Program Error
Programmers do it one finger at a time!
 
Try placing an invisible text field in the section where a new customer starts with Control Source =CapturePage([CustNo], [CustNm]) and code similar to the following in the report's code module, then use this table in a user form to select and map the customer to the required page number(s) in your print routine. You'll also want to place some code to clear out "Table1" in the Report_Open subroutine.
Code:
Option Compare Database
Option Explicit

Dim rs As Recordset

Public Function CapturePage(CustNo As String, CustName As String) As Integer
    
    rs.AddNew
    rs!CustomerNumber = CustNo
    rs!CustomerName = CustName
    rs!PageNumber = CStr(Me.Page)
    rs.Update
    
    CapturePage = Me.Page
    
End Function

Private Sub Report_Open(Cancel As Integer)
    Set rs = New Recordset
    rs.CursorType = adOpenKeyset
    rs.LockType = adLockOptimistic
    rs.Open "Table1", CurrentProject.Connection, , , adCmdTable
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top