Access 2002. No other database engine.
I'm trying another approach.
Created a Select query which has the Sum. Then trying to create an Update
query using the previous query. It gives me an error: "Operation must use
an
updateable query". Maybe you can help with this one. Below are my
queries:
QUERY1:
SELECT Sum(Nz([ImportedSFUS].[Hours],0)) AS Expr1, timesheets.EmployeeID,
timesheets.WeekEnding, timesheets.HoursWorked, timesheets.InvoiceTallyflag
FROM ImportedSFUS INNER JOIN timesheets ON (ImportedSFUS.EmpID =
timesheets.EmployeeID) AND (ImportedSFUS.Weekending =
timesheets.WeekEnding)
GROUP BY timesheets.EmployeeID, timesheets.WeekEnding,
timesheets.HoursWorked, timesheets.InvoiceTallyflag
HAVING (((timesheets.HoursWorked)=Sum(Nz([ImportedSFUS].[Hours],0))));
QUERY2:
UPDATE timesheets INNER JOIN SumOfInvoiceHours ON (timesheets.WeekEnding =
SumOfInvoiceHours.WeekEnding) AND (timesheets.EmployeeID =
SumOfInvoiceHours.EmployeeID)
SET timesheets.InvoiceTallyflag = Yes;
John Spencer said:
Anyone else?
I'm stuck. I've not seen this behavior.
What version of Access? Are you using some other database engine for the
data - Oracle, SQL, MySQL, etc?
Venus said:
They are both double. I tried CCUR on both and still the same problem.
When I use the same query as SELECT rather than UPDATE, it matches all
the
rows. Only in update it doesn't update all of them. Its frustrating.
:
Probably data related.
What type of field is HoursWorked and Hours? Double or single are
both
floating
decimal numbers and therefore can both be problematic on matching if
they
have a
decimal component.
I might try forcing them to currency type for the purpose of query
UPDATE TimeSheets INNER JOIN ImportedSFUS ON (TimeSheets.EmployeeID =
ImportedSFUS.EmpID) AND (TimeSheets.WeekEnding =
ImportedSFUS.Weekending)
SET
TimeSheets.InvoiceTallyflag = Yes
WHERE CCUR([TimeSheets]![HoursWorked]) = (SELECT
CCur(Sum(Nz([ImportedSFUS].[Hours],0)))
from ImportedSFUS where TimeSheets.EmployeeID = ImportedSFUS.EmpID)
AND
(TimeSheets.WeekEnding = ImportedSFUS.Weekending);
Also you don't need the NZ function, since Sum ignores nulls in its
calculations.
Venus wrote:
I have the following query which doesn't error out and does update
some
of
the rows but not all ????
Can't understand why its not updating all the rows.
UPDATE TimeSheets INNER JOIN ImportedSFUS ON (TimeSheets.EmployeeID
=
ImportedSFUS.EmpID) AND (TimeSheets.WeekEnding =
ImportedSFUS.Weekending) SET
TimeSheets.InvoiceTallyflag = Yes
WHERE [TimeSheets]![HoursWorked] = (select
Sum(Nz([ImportedSFUS].[Hours],0))
from ImportedSFUS where TimeSheets.EmployeeID = ImportedSFUS.EmpID)
AND
(TimeSheets.WeekEnding = ImportedSFUS.Weekending);
:
Don't waste your time with this query since you will never be able
to
use
GROUP BY like this in an update query. You might be able to use
DLookup() or
something.
--
Duane Hookom
MS Access MVP
I have an update query as below:
UPDATE TimeSheets
Set InvoiceTallyFlag = 'Yes'
From TimeSheets as TS INNER JOIN (ImportedSFUS ON TS.WeekEnding
=
ImportedSFUS.Weekending AND TS.EmployeeID = ImportedSFUS.EmpID)
Group By TS.WeekEnding, TS.EmployeeID
Having [TimeSheets]![HoursWorked] =
Sum(Nz([ImportedSFUS].[Hours],0));
Its giving me this error:
Syntax error: Missing operator.
Please help. Can't figure out where the error is.