Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hiding a field on a report (Access 2000)

    Was wondering if it's possible tohide a field on a report based on the fields value. I used this on a form and it works great. Can it be modified for a report? Thanks..

    If Me.[ReleaseOccurring] = "1/1/1970" Then
    Me.[ReleaseOccurring].Visible = False
    Else
    Me.[ReleaseOccurring].Visible = True

    End If

  2. #2
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    you sure can. run your formatting in the report detail on print event.

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    Hi Stewart...

    I was about to reply that they should put the code in the Detail - On Format event...

    I'm just curious... I've never been quite clear as to when to use which event for reports... I have read the help information, and I know the format event happens before the print event... but do you have any specific situations where to use one over the other?

    Drives me crazy when I don't know the WHY of things... <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>
    Anyone? <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    I generally use what seems appropriate and that provides the results I want.

    One of the big brains here may be able to clarify this for us.

    Now you have said that I hope I'm right, as in quick reports the on print is the one you use and I may have got my platforms confused.

  5. #5
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    I tested and it works with both events.

    I even read the help...... use the format event if you wish access to sections that do not print and to quote the help, when calculating running sums that use values from non printed sections.

    I don't see how that works myself. A non printing section should have no controls or data ????

    Can anyone clarify this???? Provide an example of this feature in action??

  6. #6
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    Glad to know that I'm not the only one who's not clear on this... <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    Access 2000 Help probably has something different, but I looked a little further into Access 97 Help and it says...

    "By running a macro or an event procedure when the Format event occurs, you can use data in the current record to make changes to the report that affect page layout. For example, you can display or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total. After the control is displayed or hidden, Microsoft Access formats the section by using the values of format properties, such as CanGrow, CanShrink, HideDuplicates, KeepTogether, and Visible.

    For changes that don't affect page layout or for event procedures or macros that should run only after the data on a page has been formatted, such as a macro that prints page totals, use the Print event for the report section."


    From the sounds of this, we should use the On Print event... It'll work in both, but making a control visible or invisible doesn't really change the layout of the section, does it?... I guess it depends on the size of the information in the control... If it were a large text control then the CanShrink/CanGrow would be needed, and therefore we should use the On Format event.... I think... <img src=/S/thinks.gif border=0 alt=thinks width=15 height=15>

    But that makes me wonder... IF we used the On Print event for this... and the control did contain a lot of data... would the section not grow to show all of the data? ...I think that's what it's saying...

    I'm going to have to play around and test this... It'll drive me <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15> until I know that I've got it...

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

    Re: hiding a field on a report (Access 2000)

    Both sets of events apply to reports, but they are different kinds of events. The OnFormat events happen on every report every time you preview or print it. The OnPrint events only happen when you print it. Format events may happen several times because Access does a lot of formatting then retreating in order to determine how to lay the report out, how many pages it has, etc. The print events only happen when the pages are printed. That's why you can see different outcomes depending on which event you put code in.
    Charlotte

  8. #8
    Star Lounger
    Join Date
    Mar 2001
    Location
    Dudley, Midlands, England
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    I'm always rather apprehensive of saying this, but I think you're incorrect here, Charlotte.

    Both the OnFormat and the OnPrint events seem to occur whenever the report generation reaches its final stage be it for printing or for previewing. The format event may occur multiple times for the same section as you say, but when the section is finally displayed or printed the OnPrint event does occur. This seems to be the case under both Access 97 and Access 2000.

    Simon

  9. #9
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hiding a field on a report (Access 2000)

    Thanks for the further explanation Charlotte... The problem is that I don't see different outcomes depending on which event I put code in... I see exactly the same outcome... Can you give me an example of something where I would see the difference? ... I mean, can you think of one time that you have chosen to use On Print rather than On Format, and why?

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

    Re: hiding a field on a report (Access 2000)

    If you want to see the difference, use an accumulator variable to count the pages or records actually printed. Compare that to the value you get when you count the pages or records from the format events without previewing every page.
    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
  •