D
Data Tim
Using Access 2003, I am trying to get calculated fields in a main form from a
subform based on criteria in the subform. I’m trying to run this based on
queries (which may not be the best option). Below is the structure on the
Main and Sub forms.
Main form (goat survey table and Total queries)
Survey key (primary key, autonumber)
Other information associated with survey (date, time, weather)
NE Sum Query (uses information from the subform, SQL posted farther down
in message, other queries differ in what Quadrant equals)
Survey Key (group by) – used to join to Survey table
Quadrant = NE (group by)
Group Total (Sum) AS NE Total
NW Sum Query
SE Sum Query
SW Sum Query
Sub form (goats detected, qry fields)
Detected key (primary key, autonumber)
Survey key (foreign key, from goat survey)
Time
Quadrant (area where goat was seen: compass point - NE, NW, SE, and SW)
Adults (number of adults, integer)
Young (number of young, integer)
Group Total (Adults + Young; total number of goat in a group)
What I would like to have on the Main form is a total field for each
Quadrant (e.g. Calculated total fields: NE Quad, NW Quad…)
The SQL statement used in the Total queries that Sums on a Quadrant (example
is from the NE quadrant):
SELECT qryGoat_Detection.Goat_Survey_Key, qryGoat_Detection.Quadrant,
Sum(qryGoat_Detection.Group_Total) AS NE_Total
FROM qryGoat_Detection
GROUP BY qryGoat_Detection.Goat_Survey_Key, qryGoat_Detection.Quadrant
HAVING (((qryGoat_Detection.Quadrant)="NE"));
The trouble I have is that if no goats were seen in a quadrant (quadrant not
entered into Goats Detected), no values for the whole query are returned
(e.g. Survey Key =1 (survey data entered); with that survey, no goats seen in
Quad SW, so SW is not entered into the Detected table. Because SW is Null,
the query returns Null for All fields (if the null sum is removed the query
returns in the values for goat survey).
I tried entering a NZ function into the query, but did not know how to
insert it (if possible) into the query statement and could not get it to
work. Would a Sum or DSum hidden in the subform’s footer and passed to the
main form work better?
All help is much appreciated. Thanks in advance.
Tim
subform based on criteria in the subform. I’m trying to run this based on
queries (which may not be the best option). Below is the structure on the
Main and Sub forms.
Main form (goat survey table and Total queries)
Survey key (primary key, autonumber)
Other information associated with survey (date, time, weather)
NE Sum Query (uses information from the subform, SQL posted farther down
in message, other queries differ in what Quadrant equals)
Survey Key (group by) – used to join to Survey table
Quadrant = NE (group by)
Group Total (Sum) AS NE Total
NW Sum Query
SE Sum Query
SW Sum Query
Sub form (goats detected, qry fields)
Detected key (primary key, autonumber)
Survey key (foreign key, from goat survey)
Time
Quadrant (area where goat was seen: compass point - NE, NW, SE, and SW)
Adults (number of adults, integer)
Young (number of young, integer)
Group Total (Adults + Young; total number of goat in a group)
What I would like to have on the Main form is a total field for each
Quadrant (e.g. Calculated total fields: NE Quad, NW Quad…)
The SQL statement used in the Total queries that Sums on a Quadrant (example
is from the NE quadrant):
SELECT qryGoat_Detection.Goat_Survey_Key, qryGoat_Detection.Quadrant,
Sum(qryGoat_Detection.Group_Total) AS NE_Total
FROM qryGoat_Detection
GROUP BY qryGoat_Detection.Goat_Survey_Key, qryGoat_Detection.Quadrant
HAVING (((qryGoat_Detection.Quadrant)="NE"));
The trouble I have is that if no goats were seen in a quadrant (quadrant not
entered into Goats Detected), no values for the whole query are returned
(e.g. Survey Key =1 (survey data entered); with that survey, no goats seen in
Quad SW, so SW is not entered into the Detected table. Because SW is Null,
the query returns Null for All fields (if the null sum is removed the query
returns in the values for goat survey).
I tried entering a NZ function into the query, but did not know how to
insert it (if possible) into the query statement and could not get it to
work. Would a Sum or DSum hidden in the subform’s footer and passed to the
main form work better?
All help is much appreciated. Thanks in advance.
Tim