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!

Count fields based on INSTR data 2

Status
Not open for further replies.

chuckca

Programmer
Mar 23, 2005
2
US
Hello,

I am using a VB.net app. to connect to an MS Access DB. I am attempting to do a total count of a "Item" field that will have several values. For example:

C10000056
C10000057
C10000058
D10000057
F10000057
R10000057

So on my report I need to total all of the C1's, D1's, F1's, etc. I have used the "expert" and all methods I have tried have come up with "The formula has an error do you still want to save it?" or similar.

Here is one of many methods I have tried...

Code:
local numberVar total := 0;

if {Inventory.Item} startswith "C1000051" then
total := total + 1;

I am new to Crystal Reports but have had no problems creating standard reports up to this point.

To recap, I simply want to add the total of all C1's, D1's etc. in the Item field. I don't need to use code, I will be perfectly happy if there is a rather simple and/or obvious solution that I have missed.

Thanks in advance for any help @ all.

Chuck





 
Dump the variables, they are not needed. Try this instead:

If left({YourField},2) ="C1" then 1 else 0

Perform a simple sum on this field.

Repeat as needed for D1, F1, etc. Or if you want a count of any of these combinations rather than different counts:

If left({YourField},2) in ["C1","D1","F1] then 1 else 0

And sum this formula.


Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
If you have a fixed number of codes C1, D1 and F1, lets say 6 or 7 then you could use running total with the instr function to count specific types

create a running total for each type
all you have to place on the evaluate section is this in the formula

left({YourField},2) = "C1"



Mo
 
Hello,

Thank you dgillz and MisterMo for your prompt post, I will use these methods as soon as I get back to the program.

Chuck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top