Thanx again.
I followed your advice and formatted the dates so I can compare them by month/year.
I used this:
Format([Med_StartDate], 'yyyymm')
Format([Med_EndDate], 'yyyymm')
curmonth = Format([Med_CurDate], 'yyyymm')
So I can compare Med_CurDate with Med_StartDate and Med_EndDate
I also realized what you wrote, that I cannot do the grouping in a form, so I created a subreport and put it in my form. I will find another way to get the functionality I was looking for.
My -new- problem is with my query's criteria. When I use the following WHERE clause, I get a 'type mismatch error', that I found out it has to do with the NULL fields:
Code:
"WHERE (Pt_ID = " & Me.Pt_ID & ") AND (Format([Med_StartDate], 'yyyymm') <= " & curmonth & ") AND (Med_EndDate IS NOT NULL) AND (Format([Med_EndDate], 'yyyymm') >= " & curmonth & ") ;"
Even if I try to exclude the rows where the [Med_EndDate] field is null, the (Format([Med_EndDate], 'yyyymm') >= " & curmonth & " still produces the 'type mismatch' error. The error does not occur when I have no Nulls in the table.
What would be the workaround to this ? Shouldn't the
Code:
AND (Med_EndDate IS NOT NULL)
get rid of the nulls?