Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Creating a variable Post Reply Post New Topic
Author Message
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Topic: Creating a variable
     Posted: 05 Feb 2008 at 2:49pm
In my report I need a column that will populate the numbers from 1 to number of records in my report. eg
no empno ename
1 3155 Matt
2 3344 kathy
3 8890 Piyush
4 8908 Ram
5 0098 Ann
6 9876 Christina

The database does not have a field "no" but has fields "empno", and "ename". I need to have a field "no"
I created a formula

whilereadingrecords;
Global numbervar y;
y := y + 1

When I do not have any groups, it works fine after I put the formula in the detail section. But after I insert groups, It does not work.
I have 2 groups and I have to hide the first group and hide the details section.

How can I accomplish this?

Thanks in advance
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Feb 2008 at 12:12am
Hi
 
Replace the firstline use the below formula...and place in details section...
 
Read on Pass in crystal Reports .....
 
whilePrintingrecords;
Global numbervar y;
y := y + 1
 
Cheers
Rahul


Edited by rahulwalawalkar - 06 Feb 2008 at 12:13am
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 06 Feb 2008 at 5:20am
Incidentally, you may also be able to use the RecordNumber function.  This just gives the sequential number of the record.  Of course, given your requirement for suppressing the first group, that may not work for you.

Can you be a little more specific in how it "does not work?"


IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 06 Feb 2008 at 8:17am
When I put the variable in the details section It works just fine without changing the formula.
The no. field (please see the initial post for column names) is sequential 1,2,3, 4, 5, 6 and so on.
But when I have to suppress the details section and put the field in group header, the sequence is 1,16,18,24,28,30,35 which should be 1,2,3,4,5,6,7 and so on.

My variable should be in group header because I am using summary functions and all the data should be displayed in the group header( That is why I have all objects in group header).

I tried using the recordnumber function but it has the same problem.

I tried Rahul's formula. It worked fine after I put that in the group header section.

Thank you Rahul and Lugh


Edited by fusion - 06 Feb 2008 at 8:30am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum