Getting data from a Sub Report

  • Thread starter Thread starter Dib
  • Start date Start date
D

Dib

Hi,

I am getting an error in doing this

I have a text box in a Sub Report and I am trying to get its value to a text
box on the Main Report


=[Reports]![Report2]![txtOutdate]

#Name error .

I tried in the code window on Report Formatt

I am using the DateDiff("n",txtInDate, me.Report2!txtOutDate) it gives an
error
DateDiff("n",txtInDate, me!Report2.txtOutDate) gives an error

DateDiff("n",txtInDate, Reports!Report2!txtOutDate) gives an error
DateDiff("n",txtInDate, Reports!Report2.txtOutDate) gives an error

I am using Access 2000 SP1

Please advice on what you think is wrong

Thanks
Dib
 
Firstly, subreports are not open in their own right, i.e. they are not part
of the Reports collection.

Secondly, you can only refer to the value in a report at the moment the
section is being formatted or printed (i.e. the Format or Print event of
that section).

Assuming the subreport control is named "Report2", you refer to the report
in that control like this:
=[Report2].[Report].[txtOutDate]

However, that generates an error if there are no records in the subreport
for the record in the main report, so you need to test the HasData property
of the subreport. It therefore ends up like this:
=IIf([Report2].[Report].HasData, [Report2].[Report].[txtOutDate], Null)

If that still does not work for you, double-check the Name of the subreport
control. Its Name can be different from the name of the report loaded into
the control (i.e. its SourceObject).
 
Thanks

Dib
Allen Browne said:
Firstly, subreports are not open in their own right, i.e. they are not
part of the Reports collection.

Secondly, you can only refer to the value in a report at the moment the
section is being formatted or printed (i.e. the Format or Print event of
that section).

Assuming the subreport control is named "Report2", you refer to the report
in that control like this:
=[Report2].[Report].[txtOutDate]

However, that generates an error if there are no records in the subreport
for the record in the main report, so you need to test the HasData
property of the subreport. It therefore ends up like this:
=IIf([Report2].[Report].HasData, [Report2].[Report].[txtOutDate], Null)

If that still does not work for you, double-check the Name of the
subreport control. Its Name can be different from the name of the report
loaded into the control (i.e. its SourceObject).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dib said:
I am getting an error in doing this

I have a text box in a Sub Report and I am trying to get its value to a
text box on the Main Report


=[Reports]![Report2]![txtOutdate]

#Name error .

I tried in the code window on Report Formatt

I am using the DateDiff("n",txtInDate, me.Report2!txtOutDate) it gives an
error
DateDiff("n",txtInDate, me!Report2.txtOutDate) gives an error

DateDiff("n",txtInDate, Reports!Report2!txtOutDate) gives an error
DateDiff("n",txtInDate, Reports!Report2.txtOutDate) gives an error

I am using Access 2000 SP1

Please advice on what you think is wrong

Thanks
Dib
 
Back
Top