J
Jack Sheet
Hi all
I am having difficulty understanding under which circumstances I should be
using Max() as opposed to DMax() functions. Both seem to do the same thing
(find maximum value in a field), but DMax has additional arguments.
What I currently want sounds like neither of these, as I want to query the
maximum of several values in various fields for a specific record, rather
than the maximum of several records in a specific field. Is there a way of
doing this otherwise than by nesting IIF functions several deep?
I keep running into "Microsoft Office Access has encountered an error and
needs to close" error messages, and am coming around to the view that I may
need a UDF. I have never done one in Access before (but did some time ago
in Excel).
Currently I have fields in various tables:
T_Clients.Commencement
T_Clients.Cessation
T_Tasks.StartDate
T_Tasks.EndDate
There is a one (T_Clients.ID_Clients) to many (T_Tasks.ID_Clients)
relationship
T_Clients.ID_Clients and T_Tasks_ID_Tasks are primay keys.
In "pseudocode" my query, probably via a UDF, needs to return:
Min(Max(StartDate,Commencement)+12months,Min(EndDate,(Max(Cessation,StartDate))+9months
Commencement and Cessation may contain Null values, which are then to be
treated as #1900-01-01# for the purposes of any comparisons.
My first attempt at this was to create several queries, each based on the
previous query. Inefficient, perhaps, but I could trace the logic. I
started by creating queries that substituted #1900-01-01# for null values in
the Commencement and Cessation fields.
However when I got about 3 queries deep I ran into the "Access has
encountered an error and needs to
close" error, and no amount of playing around with it stopped that.
I don't know if relevant but I don't *really* have a T_Tasks.StartDate
field. I have a query that calculates the start date from the previous
EndDate, but I did not want to complicate the problem specs. That query
seems to work ok. If I get a solution to the above I hope to jigger it to
fit.
I am having difficulty understanding under which circumstances I should be
using Max() as opposed to DMax() functions. Both seem to do the same thing
(find maximum value in a field), but DMax has additional arguments.
What I currently want sounds like neither of these, as I want to query the
maximum of several values in various fields for a specific record, rather
than the maximum of several records in a specific field. Is there a way of
doing this otherwise than by nesting IIF functions several deep?
I keep running into "Microsoft Office Access has encountered an error and
needs to close" error messages, and am coming around to the view that I may
need a UDF. I have never done one in Access before (but did some time ago
in Excel).
Currently I have fields in various tables:
T_Clients.Commencement
T_Clients.Cessation
T_Tasks.StartDate
T_Tasks.EndDate
There is a one (T_Clients.ID_Clients) to many (T_Tasks.ID_Clients)
relationship
T_Clients.ID_Clients and T_Tasks_ID_Tasks are primay keys.
In "pseudocode" my query, probably via a UDF, needs to return:
Min(Max(StartDate,Commencement)+12months,Min(EndDate,(Max(Cessation,StartDate))+9months
Commencement and Cessation may contain Null values, which are then to be
treated as #1900-01-01# for the purposes of any comparisons.
My first attempt at this was to create several queries, each based on the
previous query. Inefficient, perhaps, but I could trace the logic. I
started by creating queries that substituted #1900-01-01# for null values in
the Commencement and Cessation fields.
However when I got about 3 queries deep I ran into the "Access has
encountered an error and needs to
close" error, and no amount of playing around with it stopped that.
I don't know if relevant but I don't *really* have a T_Tasks.StartDate
field. I have a query that calculates the start date from the previous
EndDate, but I did not want to complicate the problem specs. That query
seems to work ok. If I get a solution to the above I hope to jigger it to
fit.