Results 1 to 3 of 3
  1. #1
    LlamaLima is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    2

    Supressing .pdf creation in acOutputTo

    Hi,

    I am using VBA in Access 2007 and have the following code on a button in a stand alone form (form isn't tied to any data);

    DoCmd.OutputTo acOutputReport, "rpt25+Anes", acFormatPDF, "Z:\Erx\Anes25+.pdf", False
    DoCmd.OutputTo acOutputReport, "rpt25+Barb", acFormatPDF, "Z:\Erx\Barb25+.pdf", False
    DoCmd.OutputTo acOutputReport, "rpt25+CUH", acFormatPDF, "Z:\Erx\CUH25+.pdf", False

    The code works fine, the problem is that the second report, "rpt25+Barb" doesn't have any data yet. So I wind up creating a .pdf for my admin to send out that is empty. I create these reports every month. Down the road that second report will have some data at some point and so I want to have that report ready to go when that does happen.



    Now is there a way to check to see if the second report has data and if not, jump to the next OutputTo? If the second report does have data, follow thorough with the OutputTo command.

    I have tried playing with HasData property, but I don't know how to reference the report from the VBA code on my form.

    Thanks!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    yes you can count the number of records in the query driving the report before you print it and if there are 0 records just skip to the next report.

    If your report is based on a a query (Call it query1)

    You can have code like this

    if dcount("*", "Query1") >0 then
    'Issue your print command
    endif

  3. #3
    LlamaLima is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    2
    Rpeare,


    Thanks! Yes, the reports are all based on queries. I'll give this a shot on Tuesday.

    --Mike

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Page creation
    By meliss421 in forum Access
    Replies: 6
    Last Post: 08-11-2011, 07:57 AM
  2. Macro Creation
    By lucy1216 in forum Access
    Replies: 4
    Last Post: 09-27-2010, 11:39 PM
  3. Report Creation Help
    By John.Impresst in forum Reports
    Replies: 0
    Last Post: 06-22-2010, 11:27 AM
  4. MDE Creation problem
    By bbylls in forum Access
    Replies: 24
    Last Post: 01-01-2010, 10:55 AM
  5. Will Pay $$$ for help w/ database creation!
    By eyesbryte in forum Access
    Replies: 1
    Last Post: 07-03-2006, 01:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums