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

Count array values

Status
Not open for further replies.

stancer

Programmer
Jan 16, 2003
27
0
0
US
Platform: CR 9 on WIN2K reading an Access database.

Question: I've created a standard report and want to display a count of values for one field in the footer. The field (PREMISES in table 1 CRIME) can contain any string value, i.e., ALLEY, STREET, PARKING LOT, etc. The string values are not static and I would like to find a way to list each PREMISE value and the number of times it appears on the report.

I thought I could use an array to do this and have inserted three formulas in the report:

Report Header (suppressed)
whileprintingrecords;
Global stringvar datalist := "";

Details (suppressed)
whileprintingrecords;
Global stringvar datalist;
datalist:= {1_Crime.Premises} + "," + datalist;

Report Footer
whileprintingrecords;
Global stringvar datalist;
datalist;

The variable display in the footer looks like:
PARKING LOT,ALLEY,ALLEY,DRIVEWAY,STREET,ALLEY,STREET,STREET,DRIVEWAY,PARKING LOT,ALLEY,CURBSIDE... and so forth

How can I get each unique string value and the count of that value into a format which would display like this:

PARKING LOT 2
ALLEY 4
STREET 3
DRIVEWAY 2
CURBSIDE 1

I cannot group on the field for internal reasons.

Thanks in advance

-Dave
 
Never mind - I found a solution in a post that was being submitted as I wrote the original question.

I simply inserted a cross tab based on the PREMISES field... duh! Nothing like trying to kill an ant with a sledge hammer. Don't know what I was thinking!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top