SherryScrapDog said:
Hi Marsh, Here is my SQL, then control expression:
SELECT Calendar.Day, Day.Description, Day.Month, Day.DayofMonth, Day.Year,
Employee.Employee AS Employee_Employee, Employee.Name AS Employee_Name,
Home.Name AS Home_Name, Calendar.Number, Calendar.Timeslot, Calendar.Home,
Calendar.Hours, Calendar.Employee AS Calendar_Employee, Employee.Notes
FROM Home INNER JOIN (Employee INNER JOIN ([Day] INNER JOIN Calendar ON
Day.Day = Calendar.Day) ON Employee.Employee = Calendar.Employee) ON
Home.Home = Calendar.Home
ORDER BY Calendar.Day, Calendar.Number;
=Sum(IIf(Calendar.Day<20,Calendar.Hours,0))
I double-checked to make sure Hours is numeric and it is. I tried using
brackets around the table name fields in the expression, ( ) around the name
fields and at first tried Day and Hours (without the Calendar.). I get
#Error in the field.
This form filters for Employee from a previous screen; however, my
Sum(Hours) did work before so I don't know if that could have anything to do
with it.
I don't understand what you mean by "This form filters for
Employee from a previous screen". I don't see any filtering
in your query.
Well, your syntax looks ok, BUT ...
Just because the value in the Day field looks like a number
doesn't mean it is not a Text value. Make sure you have a
text box in the form's detail section that's bound to the
Day field and that it has nothing in its Format property.
Then switch the form to form view and check if the value is
right or left aligned. If it's left aligned, then Access
thinks it's a Text value. Do the same thing for the Hours
field.
One other possible problem is your use of reserved words for
both table and field names. I can't be sure it is a problem
here, but I'm pretty sure it will be a problem somewhere,
sometime. Allen Browne has the most complete list of
reserved words at
http://allenbrowne.com/AppIssueBadWord.html
I noticed that the MS list (not as complete as Allen's) at
http://support.microsoft.com/kb/248738/en-us
lists Day as a reserved word in a query, so, maybe(?) your
use of Day as both a table and a field name are a problem.
You have several other names (Month, Name, Year, Number,
???) that are also reserved words so check the list
carefully and (I hate to say it) change all those names to
something else. I can't be bothered ckecking such huge
lists, so I just make sure I don't use a real word as a
name.
Several of your names are also reserved words in VBA, so
even if it sneaks by in your query, it might blowup in an
Access expression or in some VBA procedure.
Note: you only need to use a table name in front of a field
name when there are two fields, e.g. Day, with the same name
in a query. That in itself is why having a field in one
table that is named the same as a field in another table is
not a good idea. You might want to consider adopting a
naming convention that avoids all these issues
http://www.granite.ab.ca/access/tablefieldnaming.htm