View Single Post
  #8  
Old April 6th, 2010, 03:54 PM posted to microsoft.public.access.gettingstarted
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Query duplicates results due to many-to-many relationships

I agree, Hide Duplicates is a shotgun, Grouping/Sorting gives you finer
control...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"KenSheridan via AccessMonster.com" u51882@uwe wrote in message
news:a61f8ca748409@uwe...
Lee Ann:

The drawback of using the HideDuplicates property is that if two incidents
on
successive dates occur at the same location then, while the new date value
will be displayed, the location value will still be suppressed, which I
doubt
you'd want.

A better option is to do as Bruce says and group the report first by date
then by location, giving each group a group header, Include the date and
location controls in their respective headers. In the Format event
procedure
of each group header section put the following line of code;

MoveLayout = False

This will cause the group header controls to print on the same lines as
the
first detail, giving you the desired layout, but showing the date and
location on the first line of each distinct date regardless of whether the
location differs or not.

Date Location Arrest Charge
05/05/2007 Bar/Nightclub Assault

Threats

Harassment
10/14/2007 Bar/Nightclub None

However, you might need to differentiate between two incidents on one
date,
in which case you'll need to bring the incident table's primary key into
play
and group the report first on the date, then on the primary key
(IncidentID
say), and then on the location. In this case give only the IncidentID and
Location group's a group header and put the date control in the former.
The
same code is used in the Format event procedures of the header sections as
before. You'd then get results like this:

Date Location Arrest Charge
05/05/2007 Bar/Nightclub Assault

Threats

Harassment
05/05/2007 Bar/Nightclub GBH
10/14/2007 Highway None

Where the assault/threats/harassment on 05/05/2007 constitute one incident
and the GBH a separate incident on 05/05/2007.

Ken Sheridan
Stafford, England

Lee Ann wrote:
Jeff,

I've looked at the grouping/sorting and hide duplicates that you've
suggested. I don't know that either of these is what I'm looking for
(unless
I'm not doing something correctly). As an quick example of what I now
see:

Date Location Arrest Charge
05/05/2007 Bar/Nightclub Assault
05/05/2007 Bar/Nightclub Threats
05/05/2007 Bar/Nightclub Harassment
10/14/2007 Highway None

and the way I'd like to see it listed on a report:

Date Location Arrest Charge
05/05/2007 Bar/Nightclub Assault

Threats

Harassment
10/14/2007 Highway None


If there are multiple "entries" (arrest charge), I'd rather see the date,
location (or other fields) listed only one.

Lee Ann

[quoted text clipped - 67 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/201004/1