Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Referencing a subreport control (A2K)

    All I want to do is turn the control on and off using the .Visible method -- simplicity itself, right? I wish.

    I know how to do this with a control in form -- piece of cake. According to the documentation I have read, I should be able to do it to a subreport control with this code:

    reports![rptname]![subrptname]![controlname].visible = false

    Specifically, in my application, that would translate to:

    reports![rptFieldTicket_flex]![SubFieldTicket]!lblPrice.visible = false

    Access refuses this, saying "you entered an expression that has an invalid reference to the property Form/Report"

    What correction is required to make this work?

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

    Re: Referencing a subreport control (A2K)

    When referring to a subform or subreport, you must use the name of the subform/subreport as a control on the main form/report. This is not necessarily the same as the name of the subform/subreport in the database window.

    If you use the correct names, your instruction should work. Whether it will do what you intended is another story.

  3. #3
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referencing a subreport control (A2K)

    Great! How does that translate into a change for me? What specifically do I need to do differently?

    My problem is not whether it performs as I want -- the problem is, it simply crashes when I try to refer to the control. I've spent hours in debug mode now, trying to find the right reference to the control, and get nowhere. Am I wrong in thinking this should be a slam-dunk?

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Referencing a subreport control (A2K)

    I think what Hans was suggesting is that you may not be referring to the correct name for the subreport control. If indeed you've checked and double-checked that, then the issue may be one of timing. You don't indicate what event your code is being triggered on, but it may be possible that you need to use a different event - for example the Load event on a report can be problematic.
    Wendell

  5. #5
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referencing a subreport control (A2K)

    That all makes sense ... but I have already checked. I verified there is no problem with the subreport and control names. That's one of the great values of dropping the de###### into Immediate Mode to look for solutions -- I can try things out with having to stop, correct, and re-run.

    I use the Report_Open event. I have used the de###### to verify that the exact statements I want, are definitely being executed as I wish. I have verified that in every case, it crashes only on an invalid reference to the subreport control. If I change the statement to reference a control on the main report, for instance, it works fine. In fact, the work was originally being done on the main report, but I had to move it to the subreport (for reasons I regret but which are beyond my control). That was when it stopped working.

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

    Re: Referencing a subreport control (A2K)

    I don't know what you want to accomplish exactly, but you can try using the code from the On Format event of the report header or perhaps the page header. Those are executed later than the On Open event, the subreport may have been initialized by then. Or try the On Format event of the report header of the subreport (the On Format event of the page header of the subreport will not occur)

  7. #7
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referencing a subreport control (A2K)

    You da man! Turns out that was the exact problem -- trying to reference the subreport control before opening the subreport. The event that worked was the detail format event within the subreport. In that context, the reference that worked was

    me.[controlname].visible = false

    Thanks again to everyone who gave this some attention and advice. Even when folks swing and miss, it is comforting to have helpers out there who care. I will repay your kindness the only way I know how, by chipping in with solutions where I can.

Posting Permissions

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