Help with report & subreport

A

Ayo

I have a form with a button to open a report that has 4 subreports. The
report is suppose to open with 2 values from the form and supposed to
determine the values displayed in the subform. But for some reason the values
are not even showing up in the main form. I used the following code, which I
have used many times on other occasions to much success. This is my first
time using it with subreports present on the form.
SummarySQL="SELECT * FROM [SITE LIST] WHERE ([Project Number]='" &
Me.cmbProjectNumber & "'" & " AND [Task Number]='" & Me.TaskNumber & "')"

Application.Echo False
DoCmd.penReport "CV_AC Summary", acViewDesign
Reports("CV_AC Summary").RecordSource=SummarySQL
DoCmd.Close acReport, "CV_AC Summary", acSaveYes
Application.Echo True

DoCmd.OpenReport "CV_AC Summary",acViewPreview
 
M

Marshall Barton

Ayo said:
I have a form with a button to open a report that has 4 subreports. The
report is suppose to open with 2 values from the form and supposed to
determine the values displayed in the subform. But for some reason the values
are not even showing up in the main form. I used the following code, which I
have used many times on other occasions to much success. This is my first
time using it with subreports present on the form.
SummarySQL="SELECT * FROM [SITE LIST] WHERE ([Project Number]='" &
Me.cmbProjectNumber & "'" & " AND [Task Number]='" & Me.TaskNumber & "')"

Application.Echo False
DoCmd.penReport "CV_AC Summary", acViewDesign
Reports("CV_AC Summary").RecordSource=SummarySQL
DoCmd.Close acReport, "CV_AC Summary", acSaveYes
Application.Echo True

DoCmd.OpenReport "CV_AC Summary",acViewPreview


To be blunt, that is a terrible way to filter a report. You
should **never** modify a report or form's design in a
running application. Design view is only there for you to
use when you are creating/modifying your application.

To filter just the main report, the standard approach is to
use the OpenReport's WhereCondifion argument:

strWhere = [Project Number]='" & Me.cmbProjectNumber _
& "' AND [Task Number]='" & Me.TaskNumber & "' "
DoCmd.OpenReport "CV_AC Summary", acViewPreview, _
WhereCondition:= strWhere
Presumably, the LinkMaster/Child properties are being used
to restrict the subreports to the related each main report
detail record.
 
A

Ayo

I tried that and I still got the same result. The problem is that, the
project number, and the task number are not showing up on the report and
this in turn makes it impossible for the subreport to work because the link
fields are the project number, and the task number.

Marshall Barton said:
Ayo said:
I have a form with a button to open a report that has 4 subreports. The
report is suppose to open with 2 values from the form and supposed to
determine the values displayed in the subform. But for some reason the values
are not even showing up in the main form. I used the following code, which I
have used many times on other occasions to much success. This is my first
time using it with subreports present on the form.
SummarySQL="SELECT * FROM [SITE LIST] WHERE ([Project Number]='" &
Me.cmbProjectNumber & "'" & " AND [Task Number]='" & Me.TaskNumber & "')"

Application.Echo False
DoCmd.penReport "CV_AC Summary", acViewDesign
Reports("CV_AC Summary").RecordSource=SummarySQL
DoCmd.Close acReport, "CV_AC Summary", acSaveYes
Application.Echo True

DoCmd.OpenReport "CV_AC Summary",acViewPreview


To be blunt, that is a terrible way to filter a report. You
should **never** modify a report or form's design in a
running application. Design view is only there for you to
use when you are creating/modifying your application.

To filter just the main report, the standard approach is to
use the OpenReport's WhereCondifion argument:

strWhere = [Project Number]='" & Me.cmbProjectNumber _
& "' AND [Task Number]='" & Me.TaskNumber & "' "
DoCmd.OpenReport "CV_AC Summary", acViewPreview, _
WhereCondition:= strWhere
Presumably, the LinkMaster/Child properties are being used
to restrict the subreports to the related each main report
detail record.
 
M

Marshall Barton

Either you are doing something really strange or the main
report does not have a text box for each of those fields.
--
Marsh
MVP [MS Access]

I tried that and I still got the same result. The problem is that, the
project number, and the task number are not showing up on the report and
this in turn makes it impossible for the subreport to work because the link
fields are the project number, and the task number.

Marshall Barton said:
Ayo said:
I have a form with a button to open a report that has 4 subreports. The
report is suppose to open with 2 values from the form and supposed to
determine the values displayed in the subform. But for some reason the values
are not even showing up in the main form. I used the following code, which I
have used many times on other occasions to much success. This is my first
time using it with subreports present on the form.
SummarySQL="SELECT * FROM [SITE LIST] WHERE ([Project Number]='" &
Me.cmbProjectNumber & "'" & " AND [Task Number]='" & Me.TaskNumber & "')"

Application.Echo False
DoCmd.penReport "CV_AC Summary", acViewDesign
Reports("CV_AC Summary").RecordSource=SummarySQL
DoCmd.Close acReport, "CV_AC Summary", acSaveYes
Application.Echo True

DoCmd.OpenReport "CV_AC Summary",acViewPreview


To be blunt, that is a terrible way to filter a report. You
should **never** modify a report or form's design in a
running application. Design view is only there for you to
use when you are creating/modifying your application.

To filter just the main report, the standard approach is to
use the OpenReport's WhereCondifion argument:

strWhere = [Project Number]='" & Me.cmbProjectNumber _
& "' AND [Task Number]='" & Me.TaskNumber & "' "
DoCmd.OpenReport "CV_AC Summary", acViewPreview, _
WhereCondition:= strWhere
Presumably, the LinkMaster/Child properties are being used
to restrict the subreports to the related each main report
detail record.
 
A

Ayo

Thanks Marshall. I found out that the problem was the data not the code.

Marshall Barton said:
Either you are doing something really strange or the main
report does not have a text box for each of those fields.
--
Marsh
MVP [MS Access]

I tried that and I still got the same result. The problem is that, the
project number, and the task number are not showing up on the report and
this in turn makes it impossible for the subreport to work because the link
fields are the project number, and the task number.

Marshall Barton said:
Ayo wrote:

I have a form with a button to open a report that has 4 subreports. The
report is suppose to open with 2 values from the form and supposed to
determine the values displayed in the subform. But for some reason the values
are not even showing up in the main form. I used the following code, which I
have used many times on other occasions to much success. This is my first
time using it with subreports present on the form.
SummarySQL="SELECT * FROM [SITE LIST] WHERE ([Project Number]='" &
Me.cmbProjectNumber & "'" & " AND [Task Number]='" & Me.TaskNumber & "')"

Application.Echo False
DoCmd.penReport "CV_AC Summary", acViewDesign
Reports("CV_AC Summary").RecordSource=SummarySQL
DoCmd.Close acReport, "CV_AC Summary", acSaveYes
Application.Echo True

DoCmd.OpenReport "CV_AC Summary",acViewPreview


To be blunt, that is a terrible way to filter a report. You
should **never** modify a report or form's design in a
running application. Design view is only there for you to
use when you are creating/modifying your application.

To filter just the main report, the standard approach is to
use the OpenReport's WhereCondifion argument:

strWhere = [Project Number]='" & Me.cmbProjectNumber _
& "' AND [Task Number]='" & Me.TaskNumber & "' "
DoCmd.OpenReport "CV_AC Summary", acViewPreview, _
WhereCondition:= strWhere
Presumably, the LinkMaster/Child properties are being used
to restrict the subreports to the related each main report
detail record.
 

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