Allen,
I really appreciate your help on this.
Yes, I had tried a Compact/Repair, but that didn't fix it.
FYI: The query (qryFData) is simply a query that combines a few lookup
tables. tblCommitmentsFundSource has a field called
ProgramSubElementID that holds an ID value of a record in qryFData.
There is one and only one ProgramSubElementID in that query, so I'm
thinking it's not that.
I'll take a look at those articles and let you know. Get some
sleep!
Thanks,
JK
Okay, it's a bit hard to tell for sure, as there seems to be another
query
involved in the source, but my guess it the way Access is interpreting
the
left joins. (Presumably you have already tried a compact/repair, to
eliminate the possibility of a bad index.)
IME, Access ignores the brackets in the FROM statement. This is despite
the
fact that:
(tblCommitmentsFundSource LEFT JOIN tblBuggetProposed) LEFT JOIN
qryFData
would give different results than:
tblCommitmentsFundSource LEFT JOIN (tblBuggetProposed LEFT JOIN
qryFData)
(We are omitting the ON clause for simplicity.)
For example, say:
- tblCommitmentsFundSource generates 1 record for ID #14492,
- tblBuggetProposed generates no record for ID #14492,
- qryFData generates 2 records for ID #14492.
Then:
(tblBuggetProposed LEFT JOIN qryFData)
would generate *no* record for ID #14492, and so:
tblCommitmentsFundSource LEFT JOIN (tblBuggetProposed LEFT JOIN
qryFData)
would generate *one* record for ID #14492.
But:
(tblCommitmentsFundSource LEFT JOIN tblBuggetProposed)
would geneate one record for ID #14492,
and so:
tblCommitmentsFundSource LEFT JOIN (tblBuggetProposed LEFT JOIN
qryFData)
would generate 2 records for ID #14492.
So, presumably the WHERE clause is causing the query optimizer to
change the
execution plan.
To be honest, I'm half asleep ATM, but if you want to investigate
whether a
change of query plan really is causing the results you are seeing,
these
links may
help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnac......
If you happen to be using Access 2007, the reg setting is:
[HKLM\SOFTWARE\Microsoft\Office\12.0\Access Connectivity
Engine\Engines\Debug] "JETSHOWPLAN"="ON"
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
Allen,
(the CustomerID = 1 was a generic statement)
Here is my original query:
SELECT tblCommitmentsFundSource.*, qryFData.*
FROM (tblCommitmentsFundSource LEFT JOIN tblBudgetProposed ON
(tblCommitmentsFundSource.Description =
tblBudgetProposed.Description)
AND (tblCommitmentsFundSource.BudgetItem =
tblBudgetProposed.BudgetItem) AND (tblCommitmentsFundSource.SubGroup
=
tblBudgetProposed.SubGroup) AND (tblCommitmentsFundSource.Group =
tblBudgetProposed.Group) AND (tblCommitmentsFundSource.Country =
tblBudgetProposed.Country)) LEFT JOIN qryFData ON
tblBudgetProposed.ProgramSubElementID = qryFData.ProgramElementID;
This returns all records - I'm using the record with ID # 14992 as an
example. It appears in this query (and report) once.
Then, when I have this query:
SELECT tblCommitmentsFundSource.*, qryFData.*
FROM (tblCommitmentsFundSource LEFT JOIN tblBudgetProposed ON
(tblCommitmentsFundSource.Description =
tblBudgetProposed.Description)
AND (tblCommitmentsFundSource.BudgetItem =
tblBudgetProposed.BudgetItem) AND (tblCommitmentsFundSource.SubGroup
=
tblBudgetProposed.SubGroup) AND (tblCommitmentsFundSource.Group =
tblBudgetProposed.Group) AND (tblCommitmentsFundSource.Country =
tblBudgetProposed.Country)) LEFT JOIN qryFData ON
tblBudgetProposed.ProgramSubElementID = qryFData.ProgramElementID
WHERE (((tblCommitmentsFundSource.ObligationID)=14992));
The results show record 14992 twice. Record 14992 only appears in
the
tblCommitmentsFundSource table once, and due to the Left Joins, I
don't see how it could appear twice in the results. I also can't
understand how the simple addition of a WHERE clause could cause
this.
On Apr 18, 10:51 pm, "Allen Browne" <
[email protected]>
wrote:
Post the SQL statement, including the WHERE CustomerID = 1.
I'm getting a very strange error: I have a report that is
displaying
records multiple times when I view it. When I look at the record
source of the report and run the query, I get the expected results
(listing each record once). If though, I limit the query (e.g.
WHERE
CustomerID = 1), either by using a WHERE clause in the query, or a
Filter on the report, the results show two records for CustomerID
1.
When I look in the table though, there is only one record for
CustomerID 1.
Anyone had any experience with something like this?
Any help would be greatly appreciated.
Thanks!
JK- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -