Thanks for your prompt response.
I tried what you said, and the problem is still there. So here is the
query
- I trust it means more to you than it does to me!
There are 2 tables:
tblMusicTeaching
tblLessons
The problem field is ynLessonCharge
SELECT tblMusicTeaching.intStudentID, tblMusicTeaching.strSurname,
tblMusicTeaching.strFirstName, tblMusicTeaching.strStatus1,
tblMusicTeaching.strStatus2, tblLessons.intLessonID,
tblLessons.intStudentAndLessonLink, tblLessons.dtLessonDate,
DatePart("m",[dtLessonDate]) AS LessonMonth,
IIf(IsNull([dtLessonDate]),0,[curLessonFee]) AS Fee,
Count(tblLessons.dtLessonDate) AS LessonCount, tblLessons.strLessonNotes,
IIf(IsNull([dtPaymentDate]),0,[curLessonFee]) AS Payment,
tblLessons.dtPaymentDate, tblLessons.intReceiptNumber,
IIf(IsNull([dtLessonDate]),[dtPaymentDate],[dtLessonDate]) AS dtDateSort,
DatePart("m",IIf(IsNull([dtLessonDate]),[dtPaymentDate],[dtLessonDate]))
AS
dtMonthSort, tblLessons.ynLessonCharge
FROM tblMusicTeaching LEFT JOIN tblLessons ON
tblMusicTeaching.intStudentID
= tblLessons.intStudentAndLessonLink
GROUP BY tblMusicTeaching.intStudentID, tblMusicTeaching.strSurname,
tblMusicTeaching.strFirstName, tblMusicTeaching.strStatus1,
tblMusicTeaching.strStatus2, tblLessons.intLessonID,
tblLessons.intStudentAndLessonLink, tblLessons.dtLessonDate,
DatePart("m",[dtLessonDate]),
IIf(IsNull([dtLessonDate]),0,[curLessonFee]),
tblLessons.strLessonNotes, IIf(IsNull([dtPaymentDate]),0,[curLessonFee]),
tblLessons.dtPaymentDate, tblLessons.intReceiptNumber,
IIf(IsNull([dtLessonDate]),[dtPaymentDate],[dtLessonDate]),
DatePart("m",IIf(IsNull([dtLessonDate]),[dtPaymentDate],[dtLessonDate])),
tblLessons.ynLessonCharge
HAVING (((tblMusicTeaching.strStatus1)="Student") AND
((tblMusicTeaching.strStatus2)<>"School"))
ORDER BY tblMusicTeaching.strSurname,
IIf(IsNull([dtLessonDate]),[dtPaymentDate],[dtLessonDate]);
--
PeterK
Allen Browne said:
Sounds like Access is confused about the names of things, or may have a
bad
index.
To fix it, try this sequence:
1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html
2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact
3. Close Access. Make a backup copy of the file. Decompile the database
by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"
4. Open Access, and compact again.
If the problem still persists, does the query involve more than one
table?
Switch it to SQL View, and post the query statement, and indicate which
is
the new yes/no field.