How can I split a report - 1st half, 2nd half

R

Russ

I need a report to divide the number of records into two parts so each
part can be assigned to two people. The number of records change
occasionally, so somehow it has to divide the total records by two and
create a page break at that location. Any ideas?

Russ
 
M

Marshall Barton

Russ said:
I need a report to divide the number of records into two parts so each
part can be assigned to two people. The number of records change
occasionally, so somehow it has to divide the total records by two and
create a page break at that location. Any ideas?


Add a text box (named txtTotalLines) to the report header
section and set its ControlSource to =Count(*)

Also add a text box (named txtLine) to the detail section.
Set its ControlSource to =1 and RunningSum to Over All.

Then add a page break control (named pgEject) at the bottom
of the detail section. Add this line of code to the detail
section's Format event procedure:
Me.pgEject.Visible = (txtTotalLines \ 2 = txtLine)
 
R

Russ

Add a text box (named txtTotalLines) to the report header
section and set its ControlSource to =Count(*)

Also add a text box (named txtLine) to the detail section.
Set its ControlSource to =1 and RunningSum to Over All.

Then add a page break control (named pgEject) at the bottom
of the detail section. Add this line of code to the detail
section's Format event procedure:
Me.pgEject.Visible = (txtTotalLines \ 2 = txtLine)

Marshall,

Everything went fine until I ran it. My Access 2k returns a message
that it can't find the macro 'Me.' I know it is not a macro, but
somehow it's not recognizing the code.

By the way, I did change the code slightly to use a forward slash (/)
instead of the backslash (\) you indicated. I figure it was a typo.

Russ
 
R

Russ

Add a text box (named txtTotalLines) to the report header
section and set its ControlSource to =Count(*)

Also add a text box (named txtLine) to the detail section.
Set its ControlSource to =1 and RunningSum to Over All.

Then add a page break control (named pgEject) at the bottom
of the detail section. Add this line of code to the detail
section's Format event procedure:
Me.pgEject.Visible = (txtTotalLines \ 2 = txtLine)


I did a little more work on it and added an Event Procedure and got
the following results:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.pgEject.Visible = (txtTotalLines / 2 = txtLine)
End Sub

Does that look right to you?

When I ran the report, it did count the records, but did not do any
page break half way thru.
 
R

Russ

Add a text box (named txtTotalLines) to the report header
section and set its ControlSource to =Count(*)

Also add a text box (named txtLine) to the detail section.
Set its ControlSource to =1 and RunningSum to Over All.

Then add a page break control (named pgEject) at the bottom
of the detail section. Add this line of code to the detail
section's Format event procedure:
Me.pgEject.Visible = (txtTotalLines \ 2 = txtLine)


Marshall,

One more thing I forgot to mention.... sorry. The report is divided
into two groups. The two groups need to be divided into two even
groups each, making two groups of 2 evenly divided groups.

After working with it a bit, I realized that it was dividing the whole
report into two even groups indicating that your code was fine. Only
trouble was I've got it sorted into two main groups already based upon
a field in the report.
 
M

Marshall Barton

Russ said:
One more thing I forgot to mention.... sorry. The report is divided
into two groups. The two groups need to be divided into two even
groups each, making two groups of 2 evenly divided groups.

After working with it a bit, I realized that it was dividing the whole
report into two even groups indicating that your code was fine. Only
trouble was I've got it sorted into two main groups already based upon
a field in the report.


You need to use the backslash because it does integer
division. Forward slash might have a fractional part so it
will not match anything when there are an odd number of
records.

To divide a report group into two halves, move the Count(*)
text box to the group header section and change the running
sum to Over Group.
 
R

Russ

You need to use the backslash because it does integer
division. Forward slash might have a fractional part so it
will not match anything when there are an odd number of
records.

To divide a report group into two halves, move the Count(*)
text box to the group header section and change the running
sum to Over Group.


Thanks Marshall, it looks like that did the trick! Learn something
every day.

Russ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top