Ken,
Your SELECT statement (save a missing comma) worked.
Here is the final version of the select statement:
SELECT [Task frequencies].Frequency, [Task frequencies].[Current period],
[Task frequencies].[Day span], [Task frequencies].[Week span], [Task
frequencies].[Month span], [Task frequencies].[Quarter span],
DatePart("yyyy",Date())*1000 +(DatePart("y",Date())*[Task frequencies].[Day
span]+0.1) +(DatePart("ww",Date())*[Task frequencies].[Week span]+0.1)
+(DatePart("m",Date())*[Task frequencies].[Month span]+0.1)
+(DatePart("q",Date())*[Task frequencies].[Quarter span]+0.1) AS
CalculatedField4
FROM [Task frequencies];
The problem remains for the UPDATE statement shown here:
UPDATE [Task frequencies] SET [Task frequencies].[Current period] =
DatePart("yyyy",Date())*1000 +(DatePart("y",Date())*[Task frequencies].[Day
span]+0.1) +(DatePart("ww",Date())*[Task frequencies].[Week span]+0.1)
+(DatePart("m",Date())*[Task frequencies].[Month span]+0.1)
+(DatePart("q",Date())*[Task frequencies].[Quarter span]+0.1);
The result in [Task frequencies].[Current period] is still zero.
I appreciate any help you might provide.
Ken Snell said:
What is the data type of Current period field?
If you run a select query similar to that shown below, do the actual and
calculated fields return the correct/expected results?
SELECT [Task frequencies].[Current period],
[Task frequencies].[Day span]
DatePart("yyyy",Date()) AS YYYYvalue,
DatePart("y",Date()) AS Yvalue,
DatePart("yyyy",Date())*1000+
DatePart("y",Date())*[Task frequencies].[Day span]
AS CalculatedField
FROM [Task frequencies];
--
Ken Snell
<MS ACCESS MVP>
MarkB said:
Ken,
I have tried the statement w/ quotes around the return type and w/
brackets
around the date function. All permutations (4 of them) yield the same
results.
Ken Snell said:
You've left out the " characters to delimit the strings in the first
argument for the DatePart function:
UPDATE [Task frequencies] SET [Task frequencies].[Current period] =
DatePart("yyyy",Date())*1000+DatePart("y",Date())*[Task frequencies].[Day
span];
--
Ken Snell
<MS ACCESS MVP>
I have created a query that is supposed to update a field (current
period)
to
a value based on the current date and the (Day span) field which
contains
non-zero values. The problem is that all results are zero.
UPDATE [Task frequencies] SET [Task frequencies].[Current period] =
DatePart(yyyy,Date())*1000+DatePart(y,Date())*[Task frequencies].[Day
span];
What am I doing wrong?