Okay, here is the new SQL for the first query. qryCalcBilling1
SELECT tblPrisoners.Prisoner, tblPrisoners.StartDate, tblPrisoners.ReleaseDate, Switch(DateSerial(DatePart("yyyy",Date()),DatePart("m",Date())-1,1)>[tblPrisoners]![ReleaseDate],Null,DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1)<=[tblPrisoners]![StartDate],Null,DateSerial(DatePart("yyyy",Date()),DatePart("m",Date())-1,1)<[tblPrisoners]![StartDate],[tblPrisoners]![StartDate],[tblPrisoners]![StartDate]<=DateSerial(DatePart("yyyy",Date()),DatePart("m",Date())-1,1),DateSerial(DatePart("yyyy",Date()),DatePart("m",Date())-1,1)) AS BegBillingDate, Switch([tblPrisoners]![ReleaseDate]>=DateSerial(DatePart("yyyy",Date()),DatePart("m",Date())-1,1) And [tblPrisoners]![ReleaseDate]<=DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1-1),[tblPrisoners]![ReleaseDate],IsNull([tblPrisoners]![ReleaseDate]) And [tblPrisoners]![StartDate]<=DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1-1),DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1-1),[tblPrisoners]![StartDate]<=DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1) And [tblPrisoners]![ReleaseDate]>=DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1),DateSerial(DatePart("yyyy",Date()),DatePart("m",Date()),1-1)) AS EndBillingDate
FROM tblPrisoners;
There was only one equal sign change but it is easier to give the SQL to you complete than instruct where to put in a single character. Just Copy and Paste.
That fixes the Jones situation. As for Green, you said in your original post that after totaling up the days you had to subtract 1 from the days because you don't get reimbursed for the last day. Each of the days calculations perform this adjustment except the incarceration and release of prisoner on the same day. I left that at 1 for billings. If Green started on 6/1/2002 and was released on 6/30/2002 that calculations to 30 days minus the 1 gives you 29. That is what the query is billing for.
Correct??
As for the prompting for the run date. The entire set of queries uses the system date to analyze your tables. To perform an analysis with a prompted date we will have to replace all of the references to Date() in the queries and replace them with a prompt. I will give it a try over the weekend and see how it works.
Bob Scriver