Results 1 to 4 of 4
  1. #1
    Gee is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Posts
    31

    Exclude columns with no data

    Is there an easy way to have a query exclude fields that are null?

    I have FieldA, FieldB, FieldC, FieldD and FieldE, with multiple rows of data.



    There is a form where the user checks a box with what data to include.

    If FieldC has no data (is unchecked), I need to exclude it from the output so the Query headers and included data would be:
    FieldA FieldB FieldD FieldE

    Is there an easy way to do this? I've been all over looking.
    The data is sent from the query to an Excel spreadsheet.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Not within the Access query object.

    Could use VBA code to open a recordset of only the desired fields then export the recordset data to Excel. However, this would not use TransferSpreadsheet method. Unless you use VBA code to modify the Access query object. This requires use of QueryDefs.
    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
    Gee is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Posts
    31
    That isn't going to work for me because the data often has several hundred "OR" statements and that crashes the Query.

    I can get the data into an Excel Spreadsheet, with the name "Delete" as the header for each of the columns to be deleted in the spread sheet...does anyone know the code to delete on open for the spreadsheet?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Whenever I need some new code for Excel manipulation I use Excel macro recorder to generate code then clean it up.

    Review http://www.ozgrid.com/VBA/auto-run-macros.htm
    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.

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

Similar Threads

  1. Printing a report and exclude all data with 0
    By jwright77 in forum Reports
    Replies: 3
    Last Post: 08-30-2012, 02:03 PM
  2. NOT not working to exclude text
    By Pedagogic368 in forum Access
    Replies: 3
    Last Post: 07-25-2012, 08:43 AM
  3. exclude field in query
    By chrisy in forum Queries
    Replies: 2
    Last Post: 10-28-2011, 09:53 AM
  4. Exclude values that appear in a certain table
    By DB2010MN26 in forum Queries
    Replies: 4
    Last Post: 09-08-2010, 02:33 PM
  5. Exclude rows to get to data/field names
    By The Stig in forum Access
    Replies: 1
    Last Post: 06-27-2010, 09:36 PM

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