Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2015-01-28
17
Medium Priority
?
616 Views
Last Modified: 2015-01-29
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
0
Comment
Question by:Karen Schaefer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
17 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 40576487
normally, a subreport will not show if there is no data to show

you can also check the subreport.hasdata  (true/False) property  on the No Data Event of your Main report

If [SubReportName1].HasData = 0 then
   ' what you need to do
end if
0
 

Author Comment

by:Karen Schaefer
ID: 40576494
will that work for each record on a continuous report?
0
 

Author Comment

by:Karen Schaefer
ID: 40576508
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40576509
what?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40576511
did you read my first post?
0
 

Author Comment

by:Karen Schaefer
ID: 40576523
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

0
 

Author Comment

by:Karen Schaefer
ID: 40576535
Screen shot of reportl

screen shot
Yellow illustrates where subreport should be hidden.

Thanks.
0
 

Author Comment

by:Karen Schaefer
ID: 40576540
Subreport w/data
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40576556
need to see the report..
0
 

Author Comment

by:Karen Schaefer
ID: 40576585
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
0
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 1000 total points
ID: 40576780
Hi Karen

I think you need to use the Format event of the (Detail?) section containing the subreport, nor the Current event.

Why don't you include the column header labels in the report header of the subreport?  That way, if there is no data and the subreport does not print, then you will not see the labels either.

Graham Mandeno [Access MVP 1996-2015]
0
 

Author Comment

by:Karen Schaefer
ID: 40577679
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
0
 

Author Comment

by:Karen Schaefer
ID: 40577691
It does not like the hasdata portion of the code.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40577734
you can only use the "hasdata" in the main report event i mentioned above.
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 40577778
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.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40577801
<But we really need to examine the report in a database to see what is going on. > I already ask about that report... :-(
0
 

Author Closing Comment

by:Karen Schaefer
ID: 40577873
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question