Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping Question 1

Status
Not open for further replies.

clydejones

Programmer
Jan 11, 2001
153
US
Hello,

Lets say I have a table with a field named "EmpNumber" in it with 10 records.

001
062
103
104
126
134
150
153
170
173

I want to place every record from the table on the crystal report. I DO NOT WANT TO MAKE A FIELD FOR EACH EMPLOYEE. If this can be done with crystal, how would the code look? I think I would have to make a formula for each record I desire to put on the report and use some sort of loop statement to get the record I want. I'm not sure as to how to set this up. Any suggestions?

Thanks in Advance,
Clyde

 
"I want to place every record from the table on the crystal report. I DO NOT WANT TO MAKE A FIELD FOR EACH EMPLOYEE."
If you insert the field Emp_Number (and other fields if you wish) in the details section of a new report, then Crystal Reports will read the database, and print the value of the field(s) once for each employee record. Malcolm
 
Yo Malcom,

Sorry bout the partial explanation of my problem. You're right Crystal shows every record for each field that's place on the report(I knew that. Sorry). What I want to do is open the details section up to 8 inches If I put the previously mention field scenario on the report, I think I would get ten pages. I only want the one page but print all ten records on one page. I know I can reduce the size of the details section to get all ten records on one page. I mainly need to know can I write formulas to loop through the field and get the records that I want when I want. My fingers are really crossed here.

Clyde
 
A strange requirement, and there are less unorthodox ways to do it, but I've seen (and done) much worse ...
Formula in 10 inch detail section, section formatted as to suppress blank section:
//Formula EmpRecords
WhilePrintingRecords ;
StringVar EmpNumber ;
EmpNumber := ToText({Table.EmpNumber},0) + chr(13) ;
If OnLastRecord then
EmpNumber
Else
"" ;
//end
This will give you an extra carriage return at the end - if that is an issue, you can tweak the formula to get rid of that too.
This will only work if your list of employee numbers is under 254 characters long. If that is a problem, then you are looking at some serious kludges, or printing the result in a group footer instead of the detail section. Malcolm
 
Malcom,

Thanks so much for all of your help. I saw where the code you sent me only printed out the LastRecord. I then printed out the FirstRecord and finally all of the records. Now to really nail my original question. How can I pick out each record? Lets say I only want record number 6. Also, is there a cool book that gives good examples of looping and such. Thanks again. You have been a great help.

Clyde
 
I think you may be modifying the formuala to print out the field, rather than the variable EmpNumber.
Hmm, I'm missing something here, Clyde
If you wrote a Record Selection formula of
{Table.EmpNumber} = 6
wouldn't that do the trick?
If you wanted the user to be prompted to supply a EmpNumber, then you could create a parameter EmpNumber, and use it in the Record Selection formula
{Table.EmpNumber} = {?EmpNumber}
I don't really understand why looping would be required here. Malcolm
 
Malcolm,
Thanks so much for your responses. They have been helpful. This report is a complex one from a formatting standpoint. I knew about and have used the "Edit Selection Formula" section of Crystal, but this gives returns for only one record. This report has several details sections that are 9.5" each totaling 6 pages. What I really want to concentrate on right now is getting the records that I want and place them where I want to and still not have more than 6 pages. I was hoping that I could this with a formula. A day or so ago, I learned there is a "RecordSelection" function. I have been trying to write a formula for each record using the RecordSelection function. Can I use the RecordSelection function in the Formula Editor? I've tried RecordSelection({tableName.filedName}) and RecordSelection(){tableName.fileName} = "2". I keep getting errors. If a person can use the RecordSelection function in the Formula editor, I would appreciate you showing me an example or directing me to a source that would show me. Man, I thank u for your time and experience.

Thanks,
Clyde
 
Malcom,
Never mind my last post. Don't think the RecordSelection formula will do what I need.

Clyde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top