updatable join queries

C

Chris

Hi all,
I have 2 queries that do similar things. I've posted
the SQL for both below (as clearly as I could format
them). The first query is the one I was using, but I found
it to be slow and I've had to make a lot of calculations
on the form which slows it down quite a bit. So I picked
up a book and started reading and this led to QUERY2
below. The second query gives me more information but I
can't edit it when it's running. At first I thought that
the problem was that I am using multiple tables in the
second query but I realised that the first also does this.
I know that I can't edit the calculated fields, but I
would like to be able to edit the basic unchanged fields
from the original table. Can anyone tell me why 1 is
updatable and the other is not. Thanks for any help,
Chris.

QUERY #1

SELECT
tblPlanningApps.ProjectID,
tblPlanningApps.DateAdPublication,
tblPlanningApps.DateLodged,
tblPlanningApps.PlanningAppID,
tblPlanningApps.PlanningDesc,
tblPlanningApps.PlanningRef,
tblPlanningApps.NewspaperID,
tblPlanningApps.Applicant,
tblPlanningApps.AdWording,
tblPlanningApps.DateDecision,
tblPlanningApps.PlanningStatus,
tblPlanningApps.PermSought,
tblPlanningApps.DateSiteNotice,
tblPlanningApps.FeeAmount,
tblPlanningApps.Notes,
tblPlanningApps.NextDueItem,
tblPlanningApps.NextDueDate,
tblPlanningApps.CurrentStatus,
tblPlanningApps.PreparedBy,
tblPlanningHistory.State,
tblPlanningHistory.DateEntered,
tblPlanningHistory.Notes,
tblPlanningHistory.EmpID,
tblPlanningHistory.PlanningHistoryID,
tblPlanningApps.bActive

FROM tblPlanningApps RIGHT JOIN tblPlanningHistory ON
tblPlanningApps.PlanningAppID =
tblPlanningHistory.PlanningAppID

WHERE (((tblPlanningHistory.PlanningHistoryID)=
[CurrentStatus]))

ORDER BY tblPlanningApps.ProjectID,
tblPlanningApps.DateAdPublication,
tblPlanningApps.DateLodged;

//END OF QUERY #1




QUERY #2

SELECT
PA.PlanningAppID,
"P" & Format(PA.PlanningAppID, "00000") AS INTERNALREF,
PH.PlanningHistoryID,
PA.ProjectID,
(SELECT Format(PR.ProjectNum,"0000") & " - " & PR.Client
& " @ " & PR.Loc_Street & ", " & PR.Loc_Town & ", " &
(SELECT County FROM tblCountys AS C WHERE
PR.CountyID=C.CountyID) FROM tblProjects AS PR WHERE
PA.ProjectID = PR.ProjectID) AS PDETAIL,
PlanningDesc,
PlanningRef,
NewspaperID,
Applicant,
AdWording,
DateAdPublication,
DateLodged,
PlanningStatus,
PermSought,
DateSiteNotice,
PA.Notes,
PA.NextDueItem,
PA.NextDueDate,
PA.CurrentStatus,
PA.PreparedBy,
(SELECT Initials FROM tblEmployees AS E WHERE
E.EmployeeID=PA.PreparedBy) AS PrepInitials,
bActive,
PH.PlanningAppID,
PH.State,
PS.EndState AS bEndState,
PS.bPositiveOutcom AS bPosOutcome,
PS.bOurResponsibility,
PH.DateEntered,
PH.Notes AS StateComments

FROM tblPlanningApps AS PA, tblPlanningHistory AS PH,
tblPlanningStates AS PS

WHERE (PA.PlanningAppID = PH.PlanningAppID) AND
(PS.PlanningStateID = PH.State);

//END OF QUERY #2
 
M

Michel Walsh

Hi,


Try to move the where criteria involving two tables into the FROM clause:


from

---------------------------------------------------------------------------
FROM tblPlanningApps AS PA, tblPlanningHistory AS PH,
tblPlanningStates AS PS

WHERE (PA.PlanningAppID = PH.PlanningAppID) AND
(PS.PlanningStateID = PH.State);
----------------------------------------------------------------------------
-


to

----------------------------------------------------------------------------
-
FROM ( tblPlanningApps AS PA
INNER JOIN tblPlanningHistory AS PH
ON PA.PlanningAppID = PH.PlanningAppID )
INNER JOIN tblPlanningStates AS PS
ON PS.PlanningStateID = PH.State
----------------------------------------------------------------------------
-



Sure, you can't edit computed expressions, but the query may be now
updateable.



Hoping it may help,
Vanderghast, Access MVP






Chris said:
Hi all,
I have 2 queries that do similar things. I've posted
the SQL for both below (as clearly as I could format
them). The first query is the one I was using, but I found
it to be slow and I've had to make a lot of calculations
on the form which slows it down quite a bit. So I picked
up a book and started reading and this led to QUERY2
below. The second query gives me more information but I
can't edit it when it's running. At first I thought that
the problem was that I am using multiple tables in the
second query but I realised that the first also does this.
I know that I can't edit the calculated fields, but I
would like to be able to edit the basic unchanged fields
from the original table. Can anyone tell me why 1 is
updatable and the other is not. Thanks for any help,
Chris.

QUERY #1

SELECT
tblPlanningApps.ProjectID,
tblPlanningApps.DateAdPublication,
tblPlanningApps.DateLodged,
tblPlanningApps.PlanningAppID,
tblPlanningApps.PlanningDesc,
tblPlanningApps.PlanningRef,
tblPlanningApps.NewspaperID,
tblPlanningApps.Applicant,
tblPlanningApps.AdWording,
tblPlanningApps.DateDecision,
tblPlanningApps.PlanningStatus,
tblPlanningApps.PermSought,
tblPlanningApps.DateSiteNotice,
tblPlanningApps.FeeAmount,
tblPlanningApps.Notes,
tblPlanningApps.NextDueItem,
tblPlanningApps.NextDueDate,
tblPlanningApps.CurrentStatus,
tblPlanningApps.PreparedBy,
tblPlanningHistory.State,
tblPlanningHistory.DateEntered,
tblPlanningHistory.Notes,
tblPlanningHistory.EmpID,
tblPlanningHistory.PlanningHistoryID,
tblPlanningApps.bActive

FROM tblPlanningApps RIGHT JOIN tblPlanningHistory ON
tblPlanningApps.PlanningAppID =
tblPlanningHistory.PlanningAppID

WHERE (((tblPlanningHistory.PlanningHistoryID)=
[CurrentStatus]))

ORDER BY tblPlanningApps.ProjectID,
tblPlanningApps.DateAdPublication,
tblPlanningApps.DateLodged;

//END OF QUERY #1




QUERY #2

SELECT
PA.PlanningAppID,
"P" & Format(PA.PlanningAppID, "00000") AS INTERNALREF,
PH.PlanningHistoryID,
PA.ProjectID,
(SELECT Format(PR.ProjectNum,"0000") & " - " & PR.Client
& " @ " & PR.Loc_Street & ", " & PR.Loc_Town & ", " &
(SELECT County FROM tblCountys AS C WHERE
PR.CountyID=C.CountyID) FROM tblProjects AS PR WHERE
PA.ProjectID = PR.ProjectID) AS PDETAIL,
PlanningDesc,
PlanningRef,
NewspaperID,
Applicant,
AdWording,
DateAdPublication,
DateLodged,
PlanningStatus,
PermSought,
DateSiteNotice,
PA.Notes,
PA.NextDueItem,
PA.NextDueDate,
PA.CurrentStatus,
PA.PreparedBy,
(SELECT Initials FROM tblEmployees AS E WHERE
E.EmployeeID=PA.PreparedBy) AS PrepInitials,
bActive,
PH.PlanningAppID,
PH.State,
PS.EndState AS bEndState,
PS.bPositiveOutcom AS bPosOutcome,
PS.bOurResponsibility,
PH.DateEntered,
PH.Notes AS StateComments

FROM tblPlanningApps AS PA, tblPlanningHistory AS PH,
tblPlanningStates AS PS

WHERE (PA.PlanningAppID = PH.PlanningAppID) AND
(PS.PlanningStateID = PH.State);

//END OF QUERY #2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

perform INNER JOIN on query results 2
Slow Join 1
SUM in a UNION query 2
can't find the right query 0
Help Disambiguate my Join 2
updatable query 1
Join on a UNION query 2
Multipe Joins!!! 7

Top