Chew407
Okay, here's what I did. I made up two small tables. I didn't use all the fields you show because some of them (IDENT_STAMP etc.) aren't clear to me.
tblIncident
INCIDENT_ID (AutoNumber field), Indexed, No duplicates
CL_CLAIMNO (Number field), Indexed, No duplicates
CLAIM_DATE (Date/Time)
AMOUNT (Currency)
tblRecovered
CL_CLAIMNO (Number field), same # as in tblIncident
CL_DATE (Date/Time), this is the date of recovery payment
AMOUNT (Currency), this is the amount of recovery payment
RELATIONSHIPS: In the Relationships window, I joined the two tables on CL_CLAIMNO, checked Referential Integrity, and the join is one-to-many. Note that the CL_CLAIMNO in tblIncident has to be indexed with no duplicates in order for this to work.
In tblIncident, I entered 4 claims. With claim numbers 12345, 23456, 34567 and 45678. I gave them dates and Amounts.
Then I built a form,
frmIncidentRecovered, based on tblIncident. Into that form I pulled a SubForm based on tblRecovered. This gives you a handy way to keep individual claims and their recovery payments together.
Then I built a second form, an unbound form called
frmDateSelect. This has on it 2 text boxes and a command button. The text boxes are called txtStartDate and txtEndDate. The command button is used to run the report I built...see three paragraphs below.
Then I built a query, called
qryIncidentRecovered. This has in it the two tables, tblIncident and tblRecovered. On the relationship line, you have two choices...(a) if you want all claims between selected dates to show in a report, make sure that the query is called to show all records from tblIncident and only those from tblRecovered where the joined fields are equal, or (b) if you only want to show claims where payments have been made between the selected dates, then make sure that the query is called to show only those where the join fields are equal.
The SQL for the query is
Code:
SELECT tblIncident.INCIDENT_ID, tblIncident.CL_CLAIMNO, tblIncident.CLAIM_DATE, tblIncident.AMOUNT, tblRecovered.CL_DATE, tblRecovered.AMOUNT
FROM tblIncident LEFT JOIN tblRecovered ON tblIncident.CL_CLAIMNO = tblRecovered.CL_CLAIMNO
WHERE (((tblRecovered.CL_DATE) Between [Forms]![frmDateSelect]![txtStartDate] And [Forms]![frmDateSelect]![txtEndDate]));
Then I built a report,
rptIncidentRecovered based on the query, pulling in the fields I wanted to show. Then I grouped on the CL-CLAIMNO field.
The way it works is this. You drive everything from frmDateSelect. You enter the StartDate and the EndDate, and then press the Command button which runs the report based on the query.
If you want, you can put an unbound text box in the Report Header, with its control source something like
="This report covers claims and recovered payments between " & Forms!frmDateSelect!txtStartDate & " and " & Forms!frmDateSelect!txtEndDate & "."
I didn't bother, in my test case scenario, to add labels etc. to make the report prettier, but this can easily be done. You can also add totals in the report footer, etc., as you choose.
Hope this model helps. You can, if you wish, create the report based on an SQL that runs OnOpen, but then you have to deal with the parameters. The model and method I have described works a whole lot better and smoother in the long run and you don't have to deal with the pop-up parameters.
Post back if you need something clarified further.
I sort of figured from the 407 in your handle that you might be from somewhere close to Toronto. I live in Guelph.
Tom