The only Event in which the Record Source of a Report may be changed is the
Report's Open Event. You may have some luck if you move the code to the Open
Event of the Report embedded in the Subreport Control.
The "normal" use of Subreports and/or Subforms is to display Records in a
table that is related many-to-one to the Record displayed in the main
Report, by using a Field in the RecordSource of the main Report and a
corresponding Field in the RecordSource of the Report embedded in the
Subreport Control in the LinkMasterFields and LinkChildFields properties of
the Subreport Control to automatically synchronize. In that case, the
RecordSource used in the subform would include all the records.
I see that your RecordSource appears to be a Stored Procedure, and I have
not done what you are attempting to do, so can't offer any specific debug
assistance.
Larry Linson
Microsoft Access MVP
"CSDunn" <cd***@valverde.edu> wrote in message
news:80**************************@posting.google.c om...
Hello,
In an Access 2003 Project that uses a SQL Server 2000 database as its
data source, I am attempting to set the RecordSource property of a sub
report called 'RptTeacherHistory2' that appears in several different
'main' reports. I have tried to use the following code;
Me.RptTeacherHistory2.Properties("RecordSource") = "EXEC
RCTeacherHistory_sp " & Me.Permnum
'RCTeacherHistory' is a proc that takes 'permnum' as a single
parameter. The link Child and Master fields are 'permnum'.
I am trying to use this code on the On Format event of the Report
Header in each of the main forms, but apparently, this is not the way
to reference the RecordSource property of the Sub Report.
Is this something that is possible to do, and if so, how can I do it?
Thanks for your help!
CSDunn