Results 1 to 4 of 4
  1. #1
    BR549's Avatar
    BR549 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    21

    Deny Export of Empty Tables

    Hello, novice here, and new member of AccessForums.net. Thank you for the access to your forums.

    My database has 4 tables of which I created queries to gather the information I need out of those tables. I created a form to do all the queries in the background and have created the commands to export the files. Which is where the rub is. If my table is empty, I want the code to ignore exporting the table and move on.

    Here is the export code:
    strPath = "C:\Users\me\Desktop\Export\Raw Data Path.xlsx"
    DoCmd.TransferSpreadsheet acExport, 10, "tbl A Path", strPath, True, "A Path"
    DoCmd.TransferSpreadsheet acExport, 10, "tbl B Path", strPath, True, "B Path"



    Thank you...

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Try:

    If DCount("*","TableA") <> 0 Then
    'export
    End If

    Are these 4 tables the same in structure?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    BR549's Avatar
    BR549 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    21
    The queries run on the four tables and create another 20 from each of the 4 for a total of 80 tables. Then I have the export set up to extract 4 tables into 1 excel file with 4 sheets. At the end of this process all the tables including the 4 are deleted and then the following month we import 4 new main tables and run the queries and exports all over again. it is a small database to cut the work down for hours of extracting all the data into a few minutes. The only thing that stays the same are the queries.

  4. #4
    BR549's Avatar
    BR549 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    21
    I did put that code in and it works like a champ. Thank you very much.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-23-2012, 10:13 PM
  2. Replies: 4
    Last Post: 11-20-2011, 01:08 PM
  3. Export all tables to 1 excel file
    By vestlink in forum Programming
    Replies: 5
    Last Post: 10-03-2011, 02:45 AM
  4. Replies: 8
    Last Post: 09-05-2011, 11:16 PM
  5. Replies: 1
    Last Post: 04-17-2011, 04:16 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