• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 754
  • Last Modified:

Record navigation in Crystal Reports

I'm woking on a report in VS 2003 using the include version of CR.  I have a situation where what appears in the current line of the detail depends on the next record.  So I have a formula like:

if Next(fld) = 0 then
"x"
Else
"y"

That's fine and working as expected.  But if the condition is TRUE I want to SKIP the next record and continue on with the record after that.

So (in phony code) what I want is:

if Next(fld) = 0 then
"x"
Next Record
Else
"y"

Is there a way to do a "next record" in CR?
0
jhance
Asked:
jhance
  • 7
  • 5
1 Solution
 
mlmccCommented:
>>Is there a way to do a "next record" in CR?
Not in the sense that you want.

If you are simply trying to not show the record then use the formula for conditional suppression

On the Detail section left marign
Right Click
Click FORMAT SECTION
Click the formula button to the right of SUPPRESS
Formula
(Not NextIsNull(Fld)) and (Next(fld) = 0)

mlmcc
0
 
jhanceAuthor Commented:
Well, perhaps I need a different approach...  Here are some more specifics on the situation, perhaps you can give some advice...

I'm attempting to create a membership directory off of a database that already exists.  People are organized into families and tied together with a family_id field.  So there is a member table like this (simplified):

member_id, family_id, first_name, last_name, addr, city, state, zip, phone, member_type

member_type is 1, 2, or 4 if the person is head of household, spouse, or dependent respectively.

I need to generate a report like:

Smith, John & Jane
(Johnny, Janey, Billy)
1234 Main St.
Chicago, IL 60609
312-555-1212

But if there is no "Jane" the top line should just be "Smith, John".  If there are no children, then that line should be left off.

So what I want to do in the code is:

if Next({member.member_type}) = 2 then
{member.first_name} + " & " + Next({member.first_name})
else
{member.first_name}

But in the case that this is true, I need to SKIP the spouse record.  Of course, I'm going to run into the same problem, only worse on the children since there can be a variable number of them.

Any suggestion on a better way to do this would be appreciated.
0
 
mlmccCommented:
Do all records have all the information?

member_id  - Index field?
family_id - Family Identification

If so try this

Add a group  on Family_Id
Sort on Member_Type

Insert a second group footer

Add the following formulas
In the report header
Name - DeclVars
Formula
whileprintingrecords;
global stringvar str_Children := "";

In the group header
Name - ClearVars
Formula
whileprintingrecords;
global stringvar str_Children ;
str_Children := "";
if (Next(Member_Type) = 2) then
  {last_name} & ", " & First_Name & " & " & Next({First_Name})
else
  {last_name} & ", " & First_Name

In the Detail section
Name - ClearVars
Formula
whileprintingrecords;
global stringvar str_Children ;
if (Member_Type = 4) then
  str_Children := str_Children & "," & {First_Name};
""

In the group Footer A
Name - DispChildren
Formula
whileprintingrecords;
global stringvar str_Children ;
if ( str_Children <> "") then
  "(" & Rgiht(str_Children,2) & ")"
else
  ""

In Group footer 2 put the address fields
{addr}
{city}  ","  {state}   {zip}             <-- Create a text box and drag these fields into it in that order
{phone}

mlmcc






0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
mlmccCommented:
One other thing - Be sure to Suppress Blank Sections

mlmcc
0
 
jhanceAuthor Commented:
That's really close to what I want.  One thing, however...

The groups get broken sometimes between the parent and the children at the end of a page even though I have the "keep together..." checkboxes set.  Any fix for that?
0
 
mlmccCommented:
There is another keep together for groups

Right click the left margin of the Group Header
Click CHANGE GROUP
I believe there is a Keep Together check box there

mlmcc
0
 
jhanceAuthor Commented:
No menu appears there.  Again, this is the CR designer in VS 2003, not the full-blown CR.  I'm not sure if that makes a difference on this point.
0
 
mlmccCommented:
It does make a difference.

Check the other menus

I don't have .Net so I can't look for it

mlmcc
0
 
jhanceAuthor Commented:
I found these checkboxes in the FORMAT SECTION/SECTION EXPERT dialog.  I also found checkboxes in the Report>Change Group Options.  All are set.
0
 
mlmccCommented:
This is for earlier versions but it still may be useful

How Different 'Keep Together' Options Affect the Report
http://support.businessobjects.com/library/kbase/articles/c2010715.asp

mlmcc
0
 
jhanceAuthor Commented:
mlmcc,

Thanks for your assistance on this.  The problem with keep together is apparently unresolvable.  The issue which has been addressed here before is that I'm using 2 columns in my report.  So while CR never broke the group apart at the end of a page, it happily does so at the end of column 1 and spills the rest into the top of column 2.

I guess I'll have to live with this...
0
 
mlmccCommented:
Glad i could help

mlmcc
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now