count unique fields in Access Report

Joined
Mar 19, 2010
Messages
1
Reaction score
0
I know that the following question has been asked a few times, but I must say I have never completely understood the answers to it. I want to count unique values in a particular field in a structured report.

In the detailed section of the report I have, for example:

Field [ID] Field [Destination]
ID1 Hamburg
ID2 London
ID3 Munic
ID2 Paris
ID3 Lyon
ID3 Basel

In the header (or the footer), I would like to write something like :

"3 IDs went to 6 destinations".

I don't really care how one would arrive there, but I would need to know what to put into that box to make it happen. I thought along the lines of the following, but might be completely off:

I can easily count the destinations, e.g., putting a box in the report of the type

= count([ID])

I would love be able to have a function such as :

=unique([ID])

I wrote a function of the type:

function funcShowRecord(MyVar as String) as String

and call it in the box as =funcShowRecord([ID])

the function was able to show me the first item of the list above. But that's obviously not enough. If I delcare:

function funcShowRecord(MyVar() as String) as String

I get an error message.

Now, writing the function is not a problem, but I don't know how to pass on [ID] as a variable. Obviously, the report knows how to pass on this as a variable, but I don't know what type it would be.

Again, I might go about it completely wrong, but perhaps you guys have an idea.

Thanks in advance
 
Back
Top