Referencing 'RecordSource' in a Sub Report

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CSDunn

    #1

    Referencing 'RecordSource' in a Sub Report

    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 'RptTeacherHist ory2' that appears in several different
    'main' reports. I have tried to use the following code;

    Me.RptTeacherHi story2.Properti es("RecordSourc e") = "EXEC
    RCTeacherHistor y_sp " & Me.Permnum

    'RCTeacherHisto ry' 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
  • Larry  Linson

    #2
    Re: Referencing 'RecordSource' in a Sub Report

    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 LinkMasterField s 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" <cdunn@valverde .edu> wrote in message
    news:807dbff7.0 409290903.273c4 630@posting.goo gle.com...[color=blue]
    > 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 'RptTeacherHist ory2' that appears in several different
    > 'main' reports. I have tried to use the following code;
    >
    > Me.RptTeacherHi story2.Properti es("RecordSourc e") = "EXEC
    > RCTeacherHistor y_sp " & Me.Permnum
    >
    > 'RCTeacherHisto ry' 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[/color]


    Comment

    Working...