Report Problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a patient database in which I have subforms in a main form. The
subforms contain sequential data for changes in their status. How can I only
include the most recent record of the subform in my report?

(If I change the patients due date, it prints out his name twice, once with
the new due date and once with the old one).

I've tried everything I can think of but am not an access guru!
 
Diane:

I hope that you've include some record number for each record in the sub
form by adding an auto number field to the table that contains that data.
If you've done that then this is fairly simple.

1.) Before previewing the report, make sure you save the current record to
set the auto number field.
2.) Add a filter to the preview command code that is behind the button you
have on the form

Your code would look like this when called from a command button included on
the subreport to display the report:

Docmd.RunCommand acCmdSaveRecord
Docmd.OpenReport "YourReportName", _
acViewPreview, ,"[RecordID] = " & Me!YourAutoNumberFieldOnTheSubForm

Now if you haven't included an auto number field you can do the same thing
but may have to use a combination of fields like the Patient ID and Date to
select the proper record e.g.

Docmd.OpenReport "YourReportName", _
acViewPreview, ,"[PatientID] = " & Me!PatientIDFieldOnTheSubForm & _
"[RecordDate] = #" & Me!DateFieldOnTheSubForm & "#"

HTH
 
Back
Top