pmacdiddie@gmail.com wrote:
Quote:
INSERT INTO tmpRaItemsInUseTotals ( [Item Number], SumOfQuantity )
SELECT DISTINCTROW tblJobsLineItems.[Item Number],
Sum(tblJobsLineItems.Quantity) AS SumOfQuantity
FROM tblJobs INNER JOIN tblJobsLineItems ON tblJobs.Job_Num =
tblJobsLineItems.Job_Num
WHERE (((tblJobs.Confirmed)<>"no") AND ((tblJobs.SetCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Confirmed)<>"no") AND ((tblJobs.fldRTSCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Confirmed)<>"no") AND
((tblJobs.SetCall)<[Forms]![frmJobs]![SetCall]) AND
((tblJobs.fldRTSCall)>[Forms]![frmJobs]![fldRTSCall]))
GROUP BY tblJobsLineItems.[Item Number];
>
Any ideas?
|
a few ...
Does everyone have his/her own copy of the front end db?
--
Rewrite the SQL.
Can you manage to check tblJobs.Confirmed<>"no" only once?
Is tblJobs.Confirmed indexed?
Is there a good reason that tblJobs.Confirmed is Text and not Boolean?
Can you get rid of the [Forms]![frmJobs]![SetCall] syntax? If frmJobs
has a module then you can use Form_frmJobs.SetCall.Value which might
allow you to see exactly what you are doing. Better yet, use a query
string and enter the form values directly into the query string as
something like
AND tblJobs.fldRTSCall Between
Between " & Form_frmJobsRTSCall.Value & " And ..."
Get rid of the Access induced parentheses and put in your own so that
can see and understand the logic of the SQL.
Can you modify the SQL so that the ORs are minimized or at least
reduced to something like
A And B And (C Or D Or E Or F).
Can you try the SQL with the most likely OR first in the SQL? Does it
make a difference? What about last?
If all this temp table does is act as a candidate table and it is
created from a Select query why make the table at all when you can just
use the Select query as the Candidate data?
--
This stuff looks like pure Microsoft exemplary code. Microsoft's code
is written with the aim of convincing computer newbies that they can do
something with Access and should buy it. It is not written with the
idea of being efficient.
Referential integrity is unlikely to make things slower, not faster.
Probably, the RI resulted in an index or two being created and that
made your query quicker.
Before you try anything I have suggested do a search on me in Google.
Try to determine if I have any clue about what I am saying. If no then
pass on to some other suggestions. When one posts here often some
replies seem to make sense and others not. But those that make sense
may do so because the poster has the same understanding of a problem as
you do; which may mean that while they contribute a nice comfortable
answer for you, they may not have contributed one which is likely to
lead you to an effective and efficient solution.