Hello Ken
Changed the SQL as you suggested - the query returns Error - "The
specified
field 'RepProduct' could refer to more than one table listed in the FROM
clause (I didn't see one in your SQL?) of your SQL statement."
So - I have four tables :-
'Categories' - with one field
CatName - Primary Key - Text - Linked One to Many with
'RepairProduct'
'RepairProduct' -with four fields
Catname - Foreign Key - Text
RepProduct - Primary Key - Text - Primary Key - Linked One to many
with
'JobDetails'
BuyPrice - Currency
SellPrice - Currency
'CustomerDetails' - with thirteen fields
JobID - Primary Key - Autonumber - Linked One to Many with
'JobDetails'
FirstName - Text
Surname - Text
TelNo - Text
CustomerRequirements - Text
DateOrdered - Date/Time
DateRequired - Date/Time
DateReady - Date/Time
DateCollected - Date/Time
WhyLate - Text
BookedInBy - Text
Paid - Yes/No
JobComplete - Yes/No
'JobDetails' - with nine fields
JobID - Number - Linked to 'CustomerDetails'
CatName - Text
RepairWhat - Text
RepProduct - Foreign Key - Text - Linked to 'RepairProduct'
Quantity - Number
Discount - Number - Percent
Repairer1 - Text
Repairer2 - Text
Repairer - Comments
And I have two queries :-
'CustomerDetails Query' - SQL as follows :-
SELECT CustomerDetails.JobID, CustomerDetails.FirstName,
CustomerDetails.Surname, CustomerDetails.TelNo,
CustomerDetails.CustomerRequirements, CustomerDetails.DateOrdered,
CustomerDetails.DateRequired, CustomerDetails.DateReady,
CustomerDetails.DateCollected, CustomerDetails.WhyLate,
CustomerDetails.BookedInBy, CustomerDetails.Paid,
CustomerDetails.JobComplete
FROM CustomerDetails;
'JobDetails Query' - SQL as follows :-
SELECT JobDetails.JobID, JobDetails.CatName, JobDetails.RepairWhat,
JobDetails.RepProduct, JobDetails.Quantity, CustomerDetails.DateOrdered,
RepairProduct.BuyPrice, RepairProduct.SellPrice, [Quantity]*[SellPrice]
AS
SubTotal, JobDetails.Discount, [SubTotal]-[SubTotal]*[Discount] AS Total,
JobDetails.Repairer1, JobDetails.Repairer2, JobDetails.RepairerComments
FROM RepairProduct INNER JOIN (CustomerDetails RIGHT JOIN JobDetails ON
CustomerDetails.JobID = JobDetails.JobID) ON RepairProduct.RepProduct =
JobDetails.RepProduct;
Hope this explains things a bit more.
Sandy
Sandy:
I suspect the problem might arise from the outer join in the JobDetails
Query. For the update query you don't need to use an outer join and
can
base
it on the tables themselves. Try this:
UPDATE RepairProduct INNER JOIN (CustomerDetails
INNER JOIN JobDetails ON CustomerDetails.JobID = JobDetails.JobID)
ON RepairProduct.RepProduct = JobDetails.RepProduct
SET BuyPrice = 4, SellPrice = 7
WHERE RepProduct = "Grip Gents"
AND DateOrdered >= #12/22/2007#;
Ken Sheridan
Stafford, England
:
Hi John
Ok I have copied my database and have deleted all of the forms. The
same
applies - on running the (what I have now called the 'PriceUpdate
Query')
all of my records (involving "Grip Gents") are changed. If I change
this
to
a select query then it runs as I would expect (only showing records
with
dates after 22/12/07).
The SQL for the UpdateQuery remains as :-
UPDATE [JobDetails Query] SET [JobDetails Query].BuyPrice = 4,
[JobDetails
Query].SellPrice = 7
WHERE ((([JobDetails Query].RepProduct)="Grip Gents") AND
(([JobDetails
Query].DateOrdered)>=#12/22/2007#));
The underlying query - JobDetails Query - has the following SQL :-
SELECT JobDetails.JobID, JobDetails.CatName, JobDetails.RepairWhat,
JobDetails.RepProduct, JobDetails.Quantity,
CustomerDetails.DateOrdered,
RepairProduct.BuyPrice, RepairProduct.SellPrice,
[Quantity]*[SellPrice]
AS
SubTotal, JobDetails.Discount, [SubTotal]-[SubTotal]*[Discount] AS
Total,
JobDetails.Repairer1, JobDetails.Repairer2,
JobDetails.RepairerComments
FROM RepairProduct INNER JOIN (CustomerDetails RIGHT JOIN JobDetails
ON
CustomerDetails.JobID = JobDetails.JobID) ON RepairProduct.RepProduct
=
JobDetails.RepProduct;
The only price changes taking place are for the "Grip Gents" - nothing
else.
Does this help?
Sandy
On Sat, 22 Dec 2007 19:15:06 -0000, "Sandy"
<
[email protected]>
wrote:
I used Date as a general term not the actual field name. Sorry guys.
The
SQL
is as follows :-
UPDATE [JobDetails Query] SET [JobDetails Query].BuyPrice = 4,
[JobDetails
Query].SellPrice = 7
WHERE ((([JobDetails Query].RepProduct)="Grip Gents") AND
(([JobDetails
Query].DateOrdered)>=#12/22/2007#));
When I click on 'Run' the message box tells me I am about to
update 2
records which would be Ok. However all of my records have been
changed.
Why?
Doublecheck. Are they actually being changed, or do you perhaps have
a
Form
with some unbound textboxes displaying data? What's the SQL of
[JobDetails
Query]? Are the prices in fact being updated in the underlying table
for
records other than "Grip Gents" December 22 orders?
John W. Vinson [MVP]