Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    250
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not printing a report with subforms if not data is entered.

    Hello everyone,

    I am designing a report in access 2010 which has four subforms included on hte report. I am trying to print the subforms only if there is data on them. I put the comand below for each subform, but for some reason those subforms that donot have data still print. Any ideas or suggestions. Thanks.

    private sub report_nodata (cancel as interger)

    cancel = true

    end sub

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    Why not set the subreport(s) to invisible if there is no data.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    If you have a subreport on a report Access automatically hides it if it has no data. So the default behaviour is what you are looking for.

    Maybe the reason this is not happening is that you are using subforms instead of subreports. I have not tested this to see what happens when you put subforms on a report.

    Standard practice is to use subforms with forms, and subreports with reports. Is there a reason you are using subforms?
    Regards
    John



  4. #4
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    250
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Patt and John,


    I just notice that they are subreports and not subforms as I have stated. I have a couple of fields that are yes/no fields and some that have a date stamp if something is put into them. All four forms have a date stamp field in them. Is there VBA code I can put to make sure it doesn't print if there is no data? Thanks for all your help.

    The interesting part is that on the other two subreports that I have on this particular report, it doesn't print any fields if there is no data.

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    As I said before, standard behaviour is for subreports not to be visible if there is no data.
    So, instead of asking "What can I do to make sure it does not print?" the question is "What am I doing that is making it print?"

    Recently I wanted some subreports to print when they had no data and could not find any way to make that happen.
    So the only explanation I can think of is that there is some data when you think there is not. Perhaps there are some "empty" records with just the linking field in them.

    Can you post a demo version of your database? Just the bare bones needed to look at these reports.
    Regards
    John



Posting Permissions

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