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

Problem with running total evaluate function

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
0
0
GB
Hiya

Crystal Version: 9.0
Database: Access 97

I have a number of running totals in my report but i am having particular problems with one of them.

The running total counts the number of visits to a patient and is evaluated using the following function:

Code:
(
{CONTACTS.PRIMARY_REASON_CARE} = "BLC"
or
{CONTACTS.PRIMARY_REASON_CARE} = "GUF"
)
or
(
instr({CONTACTS.OTHER_REASONS_CARE}, "BLC") <> 0
or
instr({CONTACTS.OTHER_REASONS_CARE}, "GUF") <> 0
)
or
(
instr({CONTACTS.INTERVENTIONS},"BLM") <> 0
or
instr({CONTACTS.INTERVENTIONS},"BLW") <> 0 
or
instr({CONTACTS.INTERVENTIONS},"SUC") <> 0
or
instr({CONTACTS.INTERVENTIONS},"URC") <> 0
or
instr({CONTACTS.INTERVENTIONS},"REC") <> 0
or
instr({CONTACTS.INTERVENTIONS},"CHY") <> 0
)

The problem is that this doesn't seem to be returning the correct values.
When i query the database directly i get different results.

Hopefully someone could shed some light on why this may be the case. I have a feeling that i have done something wrong in the evaluate formula.

Any help is much appreciated.

Thanks
 
I'd break it down into several checks that you'd then string together. One saying
Code:
{CONTACTS.PRIMARY_REASON_CARE} in ["BLC", "GUF"]

and so on. Mixing commands is always likely to go wrong.

You could also selectively remove some of the tests and see what you do get.



Madawc Williams (East Anglia)
 
Thanks for your suggestion. I've changed part of the code to what you have posted.

Upon checking each part individualy against the database the seperate formulae seem to work. The problem occurs when they are joined together.

I also tried a method of counting the relevent details according to the formulae and totalled it up in the group footer instead of a running total. This however has still not returned the expected value. I did however notice that the count was not being output where the {contacts.other_reason_care] is null. Think this may be causing a problem so i'll have to look into it.

Thanks for your response.

I'll post if i can get the problem resolved.
 
I got the problem resolved. I ended up splitting the large formula into three smaller ones. One for Interventions, one for Primary_Reason_For_Care and one for Other_Reason_For_Care. like so:

Code:
if instr({CONTACTS.INTERVENTIONS}, "BLM")<> 0 or instr({CONTACTS.INTERVENTIONS}, "BLW")<> 0 or instr({CONTACTS.INTERVENTIONS}, "SUC")<> 0 or instr({CONTACTS.INTERVENTIONS}, "URC")<> 0
or instr({CONTACTS.INTERVENTIONS}, "URC")<> 0 or instr({CONTACTS.INTERVENTIONS}, "REC")<> 0 or instr({CONTACTS.INTERVENTIONS}, "CHY")<> 0 then
1
else
0

I then created a formula @Check Total to sum the value of the three checking formualae and used a running total to evaluate all records where (@check total) > 0. This seems to have sorted my probem.

Thanks for your help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top