Use sort and page break functions together on different fields.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to sort one field first and then page break on another field.

I have a report (set of labels) that must sort on the sequence number and
then I would like to have a page break when the department changes in another
field in the report. I have tried to do this in serveal ways combiining the
sorting and grouping options, but I have not found a combination that works
the way I need it to yet.
 
Shreniuk said:
I need to sort one field first and then page break on another field.

I have a report (set of labels) that must sort on the sequence number and
then I would like to have a page break when the department changes in another
field in the report. I have tried to do this in serveal ways combiining the
sorting and grouping options, but I have not found a combination that works
the way I need it to yet.


I'm not sure that makes sense. Perhaps you could explain
what it is supposed to do in more detail? For example, how
do the sequence number and department relate? Maybe
explaining what you want from the following:

Dept SeqNum
A 1
B 2
C 3
A 4
B 5

Or, if that's a bad example, explain the charateristics of
the records and provide a better example.
 
Shreniuk:

1.) Create your sorting using the sorting and grouping dialog.
2.) At the start of the detail section, add a page break control and set its
visible property to false (which basically turns off the page break from
happening, but leaves the control there.)
3.) Add code like this to your report:

a.) in the report module, general section, add a variable like this:

Dim varLastDept as Variant

b.) In the on Print event of the detail section, add code like this:

On Error resume next
Dim varCurDept as Variant
varCurDept = Me!NameOfControlWithCurrentDepartment
If IsNull(varLastDept) or (varLastDept = varCurDept) Then
Me!NameOfPageBreakControl.Visible = False 'e.g. PageBreak034
Else
Me!NameOfPageBreakControl.Visible = True
End if
varLastDept = Me!NameOfControlWithCurrentDepartment

HTH
 
Your example is close this is more like what the data looks like:

Department field Sequence Field
1 1
1 2
1 3
2 4
2 5
3 6
3 7
7 8
7 9
7 10

So for example sequence 1-3 is made in department 1, sequence 4 & 5 are made
in department 2... sequence 8-10 is made in department 7.
Thanks for your help.
 
WOW I will give this a try. I guess I was thinking I was just using the
normal functions in the wrong order. Thank you!!
 
Based on that example, set the first row in Sorting and
Grouping to the sequence field and the second row to the
department field. Select Yes for the department group's
Group Header. Then set the group header section's
ForceNewPage proerty to Before Section.
 

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

Back
Top