Link to home
Start Free TrialLog in
Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on

Hide subreport if record is null, but display when not null

Looking for the best approach to hiding a subreport if for a record = null, else display the record.

I mean I want the titles hidden if the record = Null.

thanks,

karen
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karen Schaefer

ASKER

will that work for each record on a continuous report?
Private Sub Report_Current()
If [rptDBAQuestionsSub].HasData = 0 Then
    Me.lblOutQuestion.Visible = False
    Me.lblSuggestion.Visible = False
End If
End Sub


this is not working. where is the best place to place the code?

K
did you read my first post?
ok I tried it on the no Data event still not return the results I am expecting.

Private Sub Report_NoData(Cancel As Integer)

If [rptDBAQuestionsSub].HasData = 0 Then
    Me.rptDBAQuestionsSub.Visible = False
    Me.lblOutQuestion.Visible = False
    Me.lblResponder.Visible = False
    Me.lblSuggestion.Visible = False
Else
    Me.rptDBAQuestionsSub.Visible = True
    Me.lblOutQuestion.Visible = True
    Me.lblResponder.Visible = True
    Me.lblSuggestion.Visible = True

End If
End Sub

Open in new window

Screen shot of reportl

User generated image
Yellow illustrates where subreport should be hidden.

Thanks.
need to see the report..
pick this up in the a.m.  thanks for the input.  do you want the actual report or is the attached screen shot sufficient?

Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Graham,

Thanks for the suggestion, however, having issue with the criteria for the Detail_Format

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [rptDBAQuestionsSub].HasData = 0 Then
    Me.rptDBAQuestionsSub.Visible = False
    Me.rptDBAQuestionsSub.CanShrink = True
'    Me.lblOutQuestion.Visible = False
'    Me.lblResponder.Visible = False
'    Me.lblSuggestion.Visible = False
'    Me.lblDateCreated.Visible = False
Else
    Me.rptDBAQuestionsSub.CanShrink = False
    Me.rptDBAQuestionsSub.Visible = True
'    Me.lblOutQuestion.Visible = True
'    Me.lblResponder.Visible = True
'    Me.lblSuggestion.Visible = True
'    Me.lblDateCreated.Visible = True
End If

If [rptUseCaseSub].HasData = 0 Then
    Me.rptUseCaseSub.CanShrink = False
Else
    Me.rptUseCaseSub.CanShrink = True
End If

End Sub
It does not like the hasdata portion of the code.
you can only use the "hasdata" in the main report event i mentioned above.
You could perhaps make the entire subreport control invisible if certain criteria are met.  But we really need to examine the report in a database to see what is going on.
<But we really need to examine the report in a database to see what is going on. > I already ask about that report... :-(
thanks Graham & Rey.

I got it to work, thanks for the input


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    If Reports![rptRequirementMain]![rptDBAQuestionsSub].Report.HasData = 0 Then
       
        Reports![rptRequirementMain]![rptDBAQuestionsSub].Report.Visible = False
    Else
        Reports![rptRequirementMain]![rptDBAQuestionsSub].Report.Visible = True
    End If
   
    If Reports![rptRequirementMain]![rptUseCaseSub].Report.HasData = 0 Then
        Reports![rptRequirementMain]![rptUseCaseSub].Report.Visible = False
    Else
        Reports![rptRequirementMain]![rptUseCaseSub].Report.Visible = True
    End If

    If Me.Duplicate_Req = True Or Me.Active = False Then
        Me.lblOpsolete.Visible = True
        Reports![rptRequirementMain]![rptUseCaseSub].Report.Visible = False
        Reports![rptRequirementMain]![rptDBAQuestionsSub].Report.Visible = False
    Else
        Me.lblOpsolete.Visible = False
        Reports![rptRequirementMain]![rptUseCaseSub].Report.Visible = True
        Reports![rptRequirementMain]![rptDBAQuestionsSub].Report.Visible = True
    End If
End Sub