Results 1 to 4 of 4
  1. #1
    vinaynaran is online now Novice
    Windows 11 Office 365
    Join Date
    Oct 2025
    Posts
    1

    Do not display column when total is zeo

    Hi all,

    Part Branch1 Branch2 Branch3 Branch4 Branch5 Branch6
    2345 23 9 0 97 0 7
    45667 5 7 0 5 0 5
    78855 6 0 0 4 0 4
    55776 7 8 0 32 0 34
    45790 7 9 0 24 0 2
    45664 1 87 0 2 0 90
    49 120 0 164 0 142

    I have a table like above and I would like to create query where any branch total is ZERO do not display in output result like below.

    in short I want below output result from above table.



    Part Branch1 Branch2 Branch4 Branch6
    2345 23 9 97 7
    45667 5 7 5 5
    78855 6 0 4 4
    55776 7 8 32 34
    45790 7 9 24 2
    45664 1 87 2 90

    Please advise.
    Thanks
    Vinay

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    If your data was properly normalised, it would not be a problem- you would simply use a crosstab query to display the data. As it is you would need some complex vba code to determine the zero columns and then hide or remove the column and then move the columns to the right, left to hide the gap

    manually in a datasheet you could do this by right clicking on the header and select hide. Can also be done in vba by setting the column width property to 0

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    I would create a count for each branch for each record.
    If a branch count of zero for a branch equals the record count, then omit that branch.

    So you need to pre process the data first, then amend the sql to remove the column(s).

    Normalise your data and it would be so much easier, as mentioned.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    what you will be needing is a VBA to build your query.
    then you need a form to display the resulting query (see SampleForm on the demo).
    see the code that create the query in Module1.
    Attached Files Attached Files

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

Similar Threads

  1. Replies: 8
    Last Post: 04-11-2024, 05:04 AM
  2. Replies: 14
    Last Post: 07-13-2015, 12:47 PM
  3. Want to update a column A if column B = column C
    By AudiA4_20T in forum Queries
    Replies: 5
    Last Post: 08-08-2012, 02:42 PM
  4. Replies: 1
    Last Post: 12-08-2011, 08:03 AM
  5. Replies: 7
    Last Post: 04-27-2010, 02:47 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