Showing a Null result

P

paul bennett

I have a parent table linked to several child tables via a unique text string

The report shows reults from the main table, and has subreports for the
child tables.

Some records in the parent table have no equivalents in the child tables.
Can I insert some code to produce the subreports with a "None" or "NA" text
string, without populating the child tables with these terms?

My problem is that, I need to run "counting" queries on the child tables,
but the "N/A" records skew the numbers by adding records where there should
be none.
 
D

Duane Hookom

I'm not sure what your specific requirement is. You can use the HasData
property of the subreport control to determine if there are records in your
subreport.

This expression will display nothing if the subreport has data and a message
if there is no data.
=IIf(subrptControl.Report.HasData, Null, "No data in subrptA")
 
P

paul bennett

The parent is a physical area with several pieces of information, which are
displayed in the main (detail) section of the report.
The child is a table listing the buildings in that area and is shown in a
sub-report as a continuous form.

Presently, where there is an area with no buildings, the building sub-report
does not appear at all.

I want a report that will show the buildings in an area in the sub-report,
if there are no buildings there, to say "None Present" where the sub report
would have been
 
D

Duane Hookom

Did you attempt exactly what I suggested only changing it to reference your
subreport control name?

=IIf(subrptControl.Report.HasData, Null, "None Present")
 
P

paul bennett

Still does not return a null result - what am I doing wrong?

Enter main report in design view
Right click on sub-form (Form.tblConservationAreasCONS subreport)
"build event"

Private Sub Form_Load()
=IIf(CONS_CharacterAreaNumber.tblConservationAreasCONS_subreport.HasData,
Null, "None Present")

End Sub


Compile Error
Expected: Line Number or Label or Statement or end of statement
 
D

Duane Hookom

Quite often when I post code to be pasted into a module, users will attempt
to place it in an event "property". In your case, I should have been more
clear that this was a text box and the Control Source property should be set
to:
=IIf(tblConservationAreasCONS_subreport.Report.HasData, Null, "None Present")
This assumes your subreport control name is
"tblConservationAreasCONS_subreport".
 
P

paul bennett

Thanks for that, I was using a form as the subreport, once I changed it to a
report, this worked fine. Cheers Duane
 

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