Results 1 to 6 of 6
  1. #1
    JFord is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5

    Hiding Paragraphs (Collapsing Text) Based on Values

    I have a form that displays many different fields, but usually most of them are blank and in those cases I would like to display nothing (hide the field and its label).

    I know that I can set the Visible property, but that leaves my form looking like Swiss cheese.



    Is there any way to hide the whole paragraph so that the lines below will automatically shift up and eliminate the blank lines?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    "usually most of them are blank" - makes me suspect a non-normalized data structure.

    What do you mean by 'hide the whole paragraph'. Access has controls, not paragraphs like Word.

    Textboxes have CanGrow and CanShrink properties but the controls still occupy space and those properties don't seem to work on form, at least not that I've ever seen. They work on report, although there too the controls still occupy space, even with 0 height.
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post

    ...Textboxes have CanGrow and CanShrink properties but the controls still occupy space and those properties don't seem to work on form...They work on report
    Better to say CanGrow and CanShrink only works when printing...whether printing a Report or printing a Form (seldom a good idea) and even then they don't 'move up' to occupy empty space...that would require a good deal of additional code...having to figure out which Controls are populated...and manipulating the appropriate ones into place.

    The best workaround, for this kind of thing, would be to utilize a Tabbed Control, with the usually filled in data on the first Page, and less used Controls on other Pages. We usually think of Subforms going on Tabbed Pages, but you can simply put Controls from a single RecordSource on multiple Pages. When you reference these Controls, you do it just as if they were on a regular Form, i.e. Me.ControlName.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    JFord is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5

    Simple Example

    From the initial responses I am guessing that this can only be accomplished through a fair amount of VBA, but here is a simple example of what I want.

    Rather than the following...
    Field A: Data
    Field B: <Blank>
    Field C: <Blank>
    Field D: Data

    I want...
    Field A:Data
    Field D:Data

    Though, of course, any or all of the fields (and there are more than four) may be blank. FYI, none of these fields can be edited, but I doubt that matters.

    I used the word paragraph to indicate that the entire line should be removed.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Not making sense to do this for a form. On a report can set the textboxes Height to 0 and then position them tight against each other. They still occupy space and the white space will vary depending on which fields have data but might not be very noticeable.

    Why are you arranging the fields vertically? Exactly what kind of data is in these fields? How many fields? If the fields are not intended to be editable, just to display info, maybe should concatenate. Something like: Field1 + Chr(13) + Chr(10) & Field2 + Chr(13) + Chr(10) & Field3
    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.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,421
    sounds like your fields are in one record, in which case I would just concatenate them with line feeds.

    something like

    field1 & iif(field2 is null,"",vbcrlf & field2) & iif(field3 is null,"",vbcrlf & field3) & iif(field4 is null,"",vbcrlf & field4) etc

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

Similar Threads

  1. Hiding Text Boxes Based On User Selection VBA
    By something in forum Programming
    Replies: 10
    Last Post: 09-26-2016, 02:02 PM
  2. find values based on text criteria
    By boboivan in forum Access
    Replies: 2
    Last Post: 12-09-2015, 05:37 AM
  3. Replies: 2
    Last Post: 02-20-2014, 05:54 PM
  4. Replies: 1
    Last Post: 05-15-2013, 09:09 PM
  5. Report Design - Text Box with Paragraphs
    By sren in forum Reports
    Replies: 8
    Last Post: 12-04-2012, 01:39 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