Solved

# Record navigation in Crystal Reports

Posted on 2006-05-29
674 Views
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
Question by:jhance

LVL 100

Expert Comment

>>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

LVL 32

Author Comment

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

LVL 100

Accepted Solution

Do all records have all the information?

member_id  - Index field?
family_id - Family Identification

If so try this

Sort on Member_Type

Insert a second group footer

Name - DeclVars
Formula
whileprintingrecords;
global stringvar str_Children := "";

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
{city}  ","  {state}   {zip}             <-- Create a text box and drag these fields into it in that order
{phone}

mlmcc

0

LVL 100

Expert Comment

One other thing - Be sure to Suppress Blank Sections

mlmcc
0

LVL 32

Author Comment

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

LVL 100

Expert Comment

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

LVL 32

Author Comment

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

LVL 100

Expert Comment

It does make a difference.

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

mlmcc
0

LVL 32

Author Comment

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

LVL 100

Expert Comment

This is for earlier versions but it still may be useful

How Different 'Keep Together' Options Affect the Report

mlmcc
0

LVL 32

Author Comment

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

LVL 100

Expert Comment

mlmcc
0

## Featured Post

### Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…