Results 1 to 14 of 14
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Hiding info in report (2002)

    Hi,

    I have a report that contains a ton of data that my boss needs on a weekly basis. The report runs fine. The report contains two financial sections that she does not want the staff to see, but she does want them to get the rest of the information. I'm trying to avoid creating a second report. I'd like to set it up so that if the user clicks option 1 the boss's version opens with all data, and if they click option 2 the same report opens, but with the confidential info hidden or not visible. Is there a way to do this?

    Thanks,
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding info in report (2002)

    In what way can the two financial sections be distinguished from the rest of the report?

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    Hi Hans,

    The report is set up with tabular report with one item being [dollars]. The are multiple other items across the report. I only want to hide the information contained in [dollars] as well as the "Dollars" label if possible.

    Thanks,
    Leesha

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding info in report (2002)

    I don't understand what your new description has to do with "two financial sections", but never mind.

    I assume that you have a command button on a form that opens the report using DoCmd.OpenReport. You can pass an OpenArgs argument and use this in the code behind the report to show or hide the financial information.

    To open the report with financial information:

    DoCmd.OpenReport "NameOfReport", acViewPreview, , , , "Yes"

    and to open it without the financial information:

    DoCmd.OpenReport "NameOfReport", acViewPreview, , , , "No"

    Open the report in design view.
    Assuming that the "Dollars" text box is in the Detail section, click on (an empty part of) the Detail section.
    Activate the Event tab of the Properties window.
    Click in the On Format event.
    Select [Event Procedure] from the dropdown list.
    Click the ... to the right of the dropdown arrow.
    Make the code look like this:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.[Dollars].Visible = (Nz(Me.OpenArgs) = "Yes")
    End Sub

    Replace Dollars with the actual name of the text box, if necessary.

    Repeat this for the section containing the label (using the name of the label instead of the name of the text box).

  5. #5
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    Hi Hans,

    Yes, [dollars] is in the detail section of the report along with multiple other items. Will the same approach or a similar approach work with subreports as well? To clarify, in instances where there is a subreport containing [dollars] will that be hidden in the same manner? Or is there a way to totally hide the subreport if I choose when its printed for staff vs for the owner. I will eventually creating two reports with multiple sub reports and my goal is not to have to make one report for staff and one for the owner, but instead to hide the confidential information.

    Thanks,
    Leesha

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding info in report (2002)

    You can hide an entire subreport the same way - just use the name of the subreport as a control on the main report instead of [Dollars]. You will want to set the Can Shrink property of the subreport and of the section of the main report containing it to Yes. This will prevent the empty space that would have been occupied by the subreport from being displayed/printed.

    Note: setting Can Shrink to Yes will only move controls up to prevent empty space. It won't move controls to the left.

  7. #7
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    OMG Hans, that is wonderful! I tried it in a subreport and sure enough it worked as I hoped. To think I was going to recreate all those reports and name them differently! You've saved me oodles of time.

    Thanks!

    Leesha

  8. #8
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    Hi Again!

    Everything is working fine. Now I need to know is it possible to use the same type of an approach with a subform. In this instance I don't need to hide the subform, just the [dollars] section. When I open the subform by itself (not as a subform in a report) the [dollars] field does exactly as its told based on the option I choose for opening. When I open the report that contains the subreport, [dollars] comes up not visible in both instances. Is there a way to make [dollars] in a subreport visible or not visible based on the print option chosen?

    Thanks,
    Leesha

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding info in report (2002)

    Your post confuses me. Could you edit it and use "form", "subform", "report" and "subreport" in a consistent way?

  10. #10
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    Sorry. Here goes.

    I have a report [rptSalesUnfilledHoursDataSummary] that contains 2 subreports. The subreport [srptWeeklyUnfilledHoursData] contains [dollars]. The subreport is set to either hide the dollars or show the dollars based ont the option chosen from an option group on frmGLWeeklyTrendingReports. When I open the subreport on its own (to test the visibility of [dollars], it opens fine. When I open [rptSalesUnfilledHoursDataSummary] the [dollars] field on the subreport is always not visible. My goal, if its possible, is to have [dollars] in the subreport respond the same way it does when it's openned on its own.

    Leesha

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding info in report (2002)

    The OpenArgs argument is passed to the main report, you can't use it directly in the subreport. In the code for the subreport, replace OpenArgs by Me.Parent.Report.OpenArgs

    Note: this will cause an error if you try to open the subreport by itself, but should work OK if you open the main report.

  12. #12
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    Hi Hans,

    I'm running into error messages. I wasn't sure if I was supposed to replace the work "report" in me.Parent.Report.OpenArgs with the name of the Parent report. I tried it first exactly the way you wrote it and got an error. I then replaced the word "report" with the actual name of the report and got a different error. I tried the code both in the parent report detail section and the subreport detailed section and still got errors. I'm not sure what I'm doing wrong.

    Thanks,
    Leesha

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding info in report (2002)

    You were supposed to use the word Report literally here.

    It would be useful if you told us what error message you get.

  14. #14
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding info in report (2002)

    Hi Hans,

    Thanks for getting back to me. I didn't originally post the errors because I first wanted to be sure how I was supposed to type the code (which you explained for me here, thanks), and could then see what the error was before I spent tons of time trying to figure it out. Once I fixed the event code, the error stated something to the effect that a parameter wasn't recognized. I went back to the three subreports that are being loaded by the parent form and sure enough in one of them, [dollars] is actually called [sumofdollars] since it comes from a query that provided me with the sum. I fixed that and the report works beautifully. I'm very grateful! And, kinda tickled that I figured out the error on my own, once I had the code right. Your explanations and the explanations of others in the lounge have been a huge help in teaching this medically oriented brain to understand the code!

    Thanks,
    Leesha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •