Subreport RecordSource

R

Richard Massey

I am wanting to change the RecordSource for a subreport
based on criteria entered into a form.

The field in the form generate a piece of SQL code which
is a "Select" query. I want to automatically change the
RecordSource for my subreport when the main report is
opened.

My main report is called: "A1 Store Development ID"
My subreport is called: "D2 Status Details subreport"
and the SQL variable is called: "SQL Report Code"

I get an error message when I try. The code I am current
using after the OpenReport command (incorrectly) is:

Reports![A1 Store Development ID]![D2 Status Details
subreport]!Report!RecordSource = [SQL Report Code]

Can anyone help?
 
L

Larry Linson

Richard Massey said:
I am wanting to change the RecordSource for a subreport
based on criteria entered into a form.

The field in the form generate a piece of SQL code which
is a "Select" query. I want to automatically change the
RecordSource for my subreport when the main report is
opened.

My main report is called: "A1 Store Development ID"
My subreport is called: "D2 Status Details subreport"
and the SQL variable is called: "SQL Report Code"

I get an error message when I try. The code I am current
using after the OpenReport command (incorrectly) is:

Reports![A1 Store Development ID]![D2 Status Details
subreport]!Report!RecordSource = [SQL Report Code]

I'm afraid the Open event of the main Report may be too early, but the
statement above needs to be changed as follows (the last two !s in the
reference should be .s):

Reports![A1 Store Development ID]![D2 Status Details
subreport].Report.RecordSource = [SQL Report Code]

both are Properties and the ! isn't appropriat for Property reference.

Could you use, instead the LinkMasterFields and LinkChildFields properties
of the Subreport Control to select appropriate records, rather than creating
a different RecordSource?

Larry Linson
Microsoft Access MVP
 
R

Richard Massey

Larry,

Thanks for your comments, however, I still cannot get the
thing to work. I am using the linkMasterFields, etc. to
pull some of the records, but I am wanting to select the
first n records of the subreport based upon certain
criteria - hence the need for different RecourdSource. I
have changed the code as you suggested, but continue to
receive error messages wherever I put the code. Any
suggestions?
Rich


-----Original Message-----
I am wanting to change the RecordSource for a subreport
based on criteria entered into a form.

The field in the form generate a piece of SQL code which
is a "Select" query. I want to automatically change the
RecordSource for my subreport when the main report is
opened.

My main report is called: "A1 Store Development ID"
My subreport is called: "D2 Status Details subreport"
and the SQL variable is called: "SQL Report Code"

I get an error message when I try. The code I am current
using after the OpenReport command (incorrectly) is:

Reports![A1 Store Development ID]![D2 Status Details
subreport]!Report!RecordSource = [SQL Report Code]

I'm afraid the Open event of the main Report may be too early, but the
statement above needs to be changed as follows (the last two !s in the
reference should be .s):

Reports![A1 Store Development ID]![D2 Status Details
subreport].Report.RecordSource = [SQL Report Code]

both are Properties and the ! isn't appropriat for Property reference.

Could you use, instead the LinkMasterFields and LinkChildFields properties
of the Subreport Control to select appropriate records, rather than creating
a different RecordSource?

Larry Linson
Microsoft Access MVP




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top