Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making a label visible when printing (Access 2002)

    I have a report setup to be printed as the result of an on click event, using VBA. That works as I want. Next step is to have a label that is normally invisible to be visible when this button is clicked. You need to know that the label to become visible is on a subform.

    Thank you. Fay

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Making a label visible when printing (Access 2002)

    You address any object on a subform via the subform control name (which may or may not be the same as the actual name of the form in the subform). So, in your button's click event, you can include this to make that label visible:
    Me.subformControlName.Form!LabelName.Visible=True
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a label visible when printing (Access 2002)

    This is the line I used and it isn't working.
    Me.subrptHUDYearlyTotals.Form.lblEndReport.Visible = True
    subrptHUDYearlyTotals is the subreport name
    lblEndReport is the label that I need to be visible.

    I don't think I am sure what you meant by subformControlName. Also why is the word Form used when calling for a control on a report?

    Thanks for your help.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Making a label visible when printing (Access 2002)

    Fay,

    It wasn't clear to me whether the label in question was on your report on or a subform somewhere. It looks like Mark was equally uncertain. In Access 2000/2002, you don't actually need to use either Form or Report in the syntax (you did in earlier versions), but you will need to use a bang (!) instead of a dot between the name of the subreport control (in this case "subrptHUDYearlyTotals") and the name of the control on the subreport ("lblEndReport"). So a valid syntax would be:

    Me.subrptHUDYearlyTotals!lblEndReport.Visible = True

    However, I think you may have problems making this work. What are you using to determine whether this label is visible and why? If you're printing this report as the result of a buttonclick on a form, what purpose is served by having the label hidden in the first place? If it is necessary, why not just use the open event of the report to see if the form is open and if it is, make the label visible?
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a label visible when printing (Access 2002)

    The label in question is on the subreport. Thank you for the form info.

    You were correct the code Me.subrptHUDYearlyTotals!lblEndReport.Visible = True did not work.

    Normally this report is printed from a reports switchboard page. But at the end of the grant year I want to be able to mark the report as the year end report, hence the need to make a label visible only once. The button that is clicked is on the main form and only appears in April.

    What I wanted to happen is for the label to become visible prior to printing. How would I use the open event of the report to see if the form is open and make the label visible only when the April button is pressed on the main form? Thanks Fay

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Making a label visible when printing (Access 2002)

    >>Me.subrptHUDYearlyTotals.Form.lblEndReport.Visib le = True<<

    Oops! I'm so used to writing this for addressing subforms, that I used .Form instead of .Report! As Charlotte pointed out, you no longer need the .Form or .Report; however, I like to use them as it makes the code easier to read and understand later.

    You have to look at the name of the subreport control on the main report. What is its name. This may or may not be the same as the reportname of the report contained in the control. That's why I used "subformControlName".
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Making a label visible when printing (Access 2002)

    Are you getting the message that says you can't do this at run-time? Where are you trying to set the label to visible? You'll need to use the OnOpen event of the subreport to do this. If the button is only visible in April, then the simplest way would be to use the button's visible property to return the value for the report label's visible property. Something like this:

    Me.lblEndReport.Visible = Forms!MainForm!cmdApril.Visible

    This code would go in the OnOpen event of the subreport, and I've used MainForm for the form name and cmdApril for the name of the button.
    Charlotte

  8. #8
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a label visible when printing (Access 2002)

    I did what you said in the last post and it worked well until I tried to print the report via the "normal" way. I only want the label visible if I go throught the cmdApril button off the frmClient form. The button is only visible in April. I altered the code to the following

    Private Sub Report_Open(Cancel As Integer)
    'Makes the label "End of Year Report" visible _
    during the month of April for this report
    If Month(Date) = 4 Then
    Me.lblEndReport.Visible = True
    Else
    Me.lblEndReport.Visible = False
    End If
    End Sub

    This works. But, isn't there always a but. Can I alter the "If Month(Date) = 4 Then" line to instead be based on the fact that the cmdApril button was clicked?

    Thanks! Fay

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Making a label visible when printing (Access 2002)

    Not from the report, no. That's why I suggested referencing the month itself.
    Charlotte

Posting Permissions

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