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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data retrieval in formula field...

Status
Not open for further replies.

asimasm

Programmer
Nov 27, 2000
62
AU
Hi
Is there any way in which i may retrieve data from within a formula. Wt i mean is that in a formula i want to write a SELECT statement and open a recorset kind of object and after manipulating data in the recordset i want to return the results by the formula.
i.e something like which we do in Visual Basic code but in formula.
like

rescordset.Open("Select * from TblSomeTable");
while not (rescordset.BOF AND rescordset.EOF)
DoSomething with recordset
RecordSet.MoveNext();
end while;

Actually my problem is something like getting a list of employees seperated by a commas that belong to a against a particular DepartMent.
i.e
My report would be like
DEPARTMENT NAME EMPLOYEES
------------------------------------
Dept1 Empl1; Empl2; Emply3; Emply4
Dept2 Empl11; Empl2; Emply33; Emply44
Dept3 Empl31; Empl32; Emply3; Emply4
Dept4 Empl1; Empl2; Emply3; Emply4
Dept5 Empl1; Empl2; Emply3; Emply4

So my query returns like Department id's and names then i want to get Employee names against that department using a formula. This is only an example for my problem nature not exactly my problem. So if any body has a solution so plz let me know.

Thanks in advance
 
To do this within Crystal you could use a subreport to query the database.

You can't do this with a formula, unless you want to write a pretty sophisticated UFL function in VB to do this and then compile it as a Crystal DLL to make the function available.
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Hi
Thanks kenhamady for ur reply. That has cleared one thing that i cannot do it in formula. U mentioned that i should create a subreport for this purpose and then pass a paramenter like DepartID from my example that i gave in my first post. Now my question is that how am i to display that i a single line. i.e wt i mean is that i neen the result in a single line like

Empl1; Empl2; Emply3; Emply4

All employees against the passed department displayed as comma seperated values.

Can u get me out of this mess.
Thanks waiting for ur reply
 
You could set up multiple columns (like labels). Or you could use a formula to append them to a string variable. There is an example of this formula in faq149-243. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top