Results 1 to 11 of 11
  1. #1
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64

    Hide/Show a row on a multiple items form

    I'd like to be able to show/hide second and third rows of data on a multiple items form. I thought it would be easy - just modify the height of one of the controls on that row and watch the entire row collapse or grow based on that modification. It's not working. What's weird is, using the below code, it will collapse the row, but not enlarge it.



    Code:
    If ControlName.Height <> 0 Then
    ControlName.Height = 0
    
    
    Else
    ControlName.Height = 0.22
    
    
    End If

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    What is the default view of form - Single/Datasheet/Continueous
    Me.YourControlName.Visible=True or False can set the visibility depending on the if .. then condition you use in case of single form.
    If I understand correctly,you are using Datasheet/Continueous view of form. Try with conditional formatting based on values.

  3. #3
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Default view is continuous.
    My goal is to be able to shrink the height of the details section of the continuous form with a command button. I'm just assuming I have to be able to shrink the height of the controls within it first.

  4. #4
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    If you shrink the height of detail section, all controls will be hidden.
    You cannot selectively set the height for second or third row. The height for all the records will be same. So if the height is set to zero, the control will not be visible.
    Try with conditional formatting as suggested earlier. Set the font color similar to the background color if the condition is met.This will show an empty text box though it has data.

  5. #5
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Amrut - If I shrink the height of the detail section to 0", then all controls will be hidden... I have two rows of controls from a single record. I want to be able to shrink the second row of controls and cut the detail section height in half. Shrinking the controls doesn't seem to be a problem, but my code won't increase the height of the controls...

    Click image for larger version. 

Name:	Screenshot_1.jpg 
Views:	16 
Size:	98.0 KB 
ID:	16172

  6. #6
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    I think that you can shrink those controls and change height of detail section but it will be applicable to all the records and not the selected record only. Never tried.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Just to reiterate what's been said, you cannot do this kind of formatting using a Continuous or Datasheet View Form! In looking at your Form, when you open it, it appears that you have multiple copies of, for instance, the Ref_Dtl or the Remarks Textboxes. But as everyone knows, appearances can be deceiving, and that is the case here! There is actually only a single Ref_Dtl Textbox, and when you do anything to format it, all instances of it in all Records are formatted the same way!

    As has been said, with these types of Form Views, you need to use Conditional Formatting and, as you'll see, your options using CF are limited. You can Disable Controls with CF, or make them appear 'empty,' by setting the ForeColor to the same as the BackColor, as amrut suggested, but you cannot make the Controls disappear!

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

    All posts/responses based on Access 2003/2007

  8. #8
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    I'm perfectly OK with it applying to all instances of the details section. I understand that the details section on a continuous form is just reiterated over and over for each record and I would want it to be modified as I show for every record going down the form. And just by using a command button and the code "on click" of

    Code:
    ControlName.Height = 0
    Me.Detail.Height = 0.8
    It will shrink the row of controls and the detail sections height just fine. It just won't do the reverse. (enlarge the section)

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    The setting for Height has to be given in TWIPS (1 inch = 1440 twips) and 0 twips is the same 0 inches, so setting it to 'shrink,'using zero, will work; but setting it to 'grow,' using 2 or 4, or whatever, is being interpreted as 2 or 4 twips, which is 2/1440 or 4/1440 of an inch.

    Try using twips when you set it to 'grow.'

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

    All posts/responses based on Access 2003/2007

  10. #10
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    I'm perfectly OK with it applying to all instances of the details section.
    If this is the case then, here is the solution.
    -Note the top margins of the controls in second and third rows ( also for associated labels)as seen in the screenshoot
    -change their top margins to 0 and visibility to no
    -set the details section's height to minimum
    In the click event to show the controls - set theri visibilty to true,top to the values noted earlier
    In the click event to hide the controls - set their visibilty to false,top to 0, detail.height to 0

    The margins for the control's caption are also required to be set. I tried with only controls, but the associated labels did not moved. Only hiding the controls did not "collapsed" the details section to first row.

  11. #11
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Missinglinq - you hit the nail on the head. Works perfectly. I just didn't realize I had to give the new height in twips. I thought I was specifying in inches just like you do in the sidebar in the form design mode. When I use the same code, but figure the sizes in twips it works perfectly!

    THANK YOU SO MUCH!

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

Similar Threads

  1. Form design to show items on an order
    By snipe in forum Forms
    Replies: 6
    Last Post: 01-31-2014, 02:01 PM
  2. multiple items form
    By eraengineer in forum Forms
    Replies: 1
    Last Post: 04-17-2013, 03:33 PM
  3. Show/Hide Form
    By sparlaman in forum Forms
    Replies: 5
    Last Post: 05-16-2011, 11:48 AM
  4. Multiple Items Form - Interaction btw Fields
    By Douglasrac in forum Forms
    Replies: 15
    Last Post: 03-25-2011, 09:31 AM
  5. Replies: 6
    Last Post: 02-24-2011, 03:24 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