Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report_Open (2003)

    I would like to show or hide the details section of my report through the report_open event. I have a bound text field in my report and if the value of it is say 1000 I would like the details view to hide.

    I tried the following:

    Private Sub Report_Open(Cancel As Integer)

    If Text1 = 1000 Then
    Detail.Visible = False
    End If

    End Sub

    Thank you in advance.

  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: Report_Open (2003)

    Put your code in the Detail section's Format event. And you don't have to make it invisible. I believe just setting the Cancel option will effectively do that.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: Report_Open (2003)

    Will your report display multiple records? If so, you probably want to set the visibility for each record depending on the value of the bound field. As Mark Liquorman wrote, you have to use the On Format event of the detail section, and you must set the Visible property to True or False depending on the condition. If you only set it to False when Text1 equals 1000, it'll remain False for all subsequent records, even if they have a different value.

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.Detail.Visible = Not (Me.Text1 = 1000)
    End Sub

    or

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = (Me.Text1 = 1000)
    End Sub

  4. #4
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report_Open (2003)

    Thanks Hans but I still see the details section. it seems like it's not checking the condition. The text box control is in the footer section of my report that has a control source from the table. i tried both ways but no luck. i'm puzzled myself because i know it should work.

    any other ideas?

    thanks.

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

    Re: Report_Open (2003)

    Is the control source of the text box a field, or is it an expression (formula) beginning with = ? If the latter, what is the expression?

  6. #6
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report_Open (2003)

    It's a text field with a data control source of the query.

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

    Re: Report_Open (2003)

    Sorry for all the questions. If the control source is a field (I assume you meant that), why is the text box in the footer? Controls in the footer are filled after the rest of the report has been formatted, so the value will have no influence on the detail section.

  8. #8
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report_Open (2003)

    After I rebooted the machine it started working. There was nothing wrong with the code, but for some reason it needed a jump start.

    What's a good Access VBA source/reference?

    Thanks for the help.

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

    Re: Report_Open (2003)

    See <post#=597,983>post 597,983</post#> and <post#=502,567>post 502,567</post#> for some suggestions about learning tools and books.

    And Books on John Viescas' website lists lots of books about Access, VBA etc.

Posting Permissions

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