Report/Subreport code for Nodata? (1 Viewer)

stpiepgr

Member
Local time
Today, 01:15
Joined
Nov 6, 2002
Messages
25
I have a report that has numerous subreports. These subreports are based on different tables that may or may not have data depending on the type of survey. So for any given report, certain subreports are empty with just a header page. I would like to have a text box (txtNoData) become visible that says "No information collected" when the subreport is empty. I have tried various routines within the subreport with the "On No Data" event which does display within the subreport but I would like to have the text box display on the main report but can't figure out the code to do it. Does anybody have any better suggestions.

The code I am using in the subreport is:

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData

Me![txtNoData].Visible = True

Exit_Report_NoData:
Exit Sub

Err_Report_NoData:
MsgBox Err.DESCRIPTION, , "APPLICATIONS"
Resume Exit_Report_NoData
End Sub

Thanks.....Steve
 

Fornatian

Dim Person
Local time
Today, 01:15
Joined
Sep 1, 2000
Messages
1,396
use the HasData property of the subreport control suchas:

Dim blnShowSubRpt as Boolean

blnShowSubRpt = Me.SubRptCtl.HasData

Me.NoDataControlName.Visible = Not(blnShowSubRpt)
Me.SubFormControlName = blnShowSubForm

('Me' being the parent report)
 

stpiepgr

Member
Local time
Today, 01:15
Joined
Nov 6, 2002
Messages
25
Fornation - Thanks. I gave it a try but keep getting a "Run-time error 438" Object doesn't support this property or method. Vb debug doesn't seem to like the pink line. Any suggestions as to my inability here (lack of skill not withstanding)?

Here is what I used:
zSurvInOut = main report
zSurvInsub = sub report
txtNoData = control that is visible if no data


Private Sub Report_Open(Cancel As Integer)
Dim blnShowSubRpt As Boolean

blnShowSubRpt = Me.zSurvInSub.HasData

Me.txtNoData.Visible = Not (blnShowSubRpt)
Me.zSurvInSub = blnShowSubForm
End Sub
 
R

Rich

Guest
=IIf([SubReportName].[Report].[HasData]," ","Whatever text you want") as the control source for an unbound textbox
 

stpiepgr

Member
Local time
Today, 01:15
Joined
Nov 6, 2002
Messages
25
Rich and Fornation...I appreciate the help :) .

Rich....that worked like a charm. Don't know why I couldn't figure that one out? Guess I should stick with the old saying "K.I.S.S." (kkep it simple stuuuupid!!!)
 

Fornatian

Dim Person
Local time
Today, 01:15
Joined
Sep 1, 2000
Messages
1,396
Aaah, I missed the [report] property of subreport control from my code - cheap mistake.
 

Users who are viewing this thread

Top Bottom