Results 1 to 3 of 3
  1. #1
    Ingenium is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    2

    Subform shifting off layout when resizing other elements

    Hey All,

    I am currently working on a form which has text boxes that I want to maximize dependent on the window size. I have figured out the resizing side of things through some vb code but am having a issue were one of the subforms seems to leave the proper layout position. If I go to layout view and back to form view it seems to fix the issue but i can't find a vb command equivalent to those steps. I have attached the subform position before and after switching views:
    Click image for larger version. 

Name:	IncorrectForm.JPG 
Views:	10 
Size:	82.7 KB 
ID:	25575Click image for larger version. 

Name:	CorrectForm.JPG 
Views:	10 
Size:	72.5 KB 
ID:	25574


    The code I am using to resize other elements of the page is:
    Code:
    Private Sub Form_Resize()
        Dim WorkingPageHeight, WorkingPageWidth, HistHeight, PoAHeight, RevHeight As Integer
        
        WorkingPageHeight = Me.WindowHeight - 5000
        WorkingPageWidth = Me.WindowWidth - 8750
        
        HistHeight = WorkingPageHeight * 0.26
        PoAHeight = WorkingPageHeight * 0.56
        RevHeight = WorkingPageHeight * 0.18
        
        Me.HistoryText.Height = HistHeight
        Me.HistoryText.Width = WorkingPageWidth
        Me.PlanOfActionText.Height = PoAHeight
        Me.ReviewerNotesText.Height = RevHeight
        
        Me.ProblemReport.Width = Me.WindowWidth - 500
    
    
        Me.Repaint
    End Sub
    Is there a command that will properly position the subform in the right location?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you appear to be adjusting the width of certain controls, but not moving the subform - you either need to adjust it's left position or perhaps change the horizontal anchor to right

    By the same token, when you increase the height of historytext, you are not moving the top of planofaction down so historytext will cover or go behind planofaction - as will this control cover reviewernotes

    Note that windowheight etc refers to the dimensions of the form window - you would normally use the insideheight values for the size of the form itself. There can be differences due to the appearance or disappearance of scrollbars etc (insideheight takes them into account)

    suggest look at the move option for controls

    Me.HistoryText.move left, top, width, height

    Other thing to note with this line:

    Dim WorkingPageHeight, WorkingPageWidth, HistHeight, PoAHeight, RevHeight As Integer

    Only RevHeight is being declared as an integer, all the others are not declared as a type. Also, the type you should be using for twips is single - at some point you will get a integer overflow if you don't change it. So redeclare as

    Dim WorkingPageHeight As single, WorkingPageWidth As single, HistHeight As single, PoAHeight As single, RevHeight As single

  3. #3
    Ingenium is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    2
    Quote Originally Posted by Ajax View Post
    you appear to be adjusting the width of certain controls, but not moving the subform - you either need to adjust it's left position or perhaps change the horizontal anchor to right

    By the same token, when you increase the height of historytext, you are not moving the top of planofaction down so historytext will cover or go behind planofaction - as will this control cover reviewernotes
    So this is the weird thing, I have yet to have a issue with any of the text boxes. No matter how I scale they keep properly oriented through the tabular snap together layout. The only elements that seem to have this move issue is the subforms. I will give the movement commands specifically to the subforms to see if that fixes the issue!

    Quote Originally Posted by Ajax View Post
    Note that windowheight etc refers to the dimensions of the form window - you would normally use the insideheight values for the size of the form itself. There can be differences due to the appearance or disappearance of scrollbars etc (insideheight takes them into account)
    With this form my ultimate goal is to have no scoll bars needed, so it seems that windowheight will be getting me close to what I want. One of my side annoyances has actually been the appearance of scroll bars when it is just blank space.

    Quote Originally Posted by Ajax View Post
    Other thing to note with this line:

    Dim WorkingPageHeight, WorkingPageWidth, HistHeight, PoAHeight, RevHeight As Integer

    Only RevHeight is being declared as an integer, all the others are not declared as a type. Also, the type you should be using for twips is single - at some point you will get a integer overflow if you don't change it. So redeclare as

    Dim WorkingPageHeight As single, WorkingPageWidth As single, HistHeight As single, PoAHeight As single, RevHeight As single
    This was news to me, thanks for pointing that out!

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

Similar Threads

  1. Resizing master form when subform resizes
    By Lukael in forum Programming
    Replies: 9
    Last Post: 12-16-2015, 09:05 AM
  2. Hiding Subform Layout
    By Mahendra1000 in forum Access
    Replies: 3
    Last Post: 11-28-2013, 06:10 AM
  3. Dates shifting in Linked Spreadsheet
    By lucasjkr in forum Import/Export Data
    Replies: 6
    Last Post: 11-14-2012, 02:45 PM
  4. Subform Layout
    By lrobbo314 in forum Access
    Replies: 7
    Last Post: 03-31-2012, 08:58 AM
  5. Resizing a subform
    By tobydobo in forum Forms
    Replies: 3
    Last Post: 09-29-2011, 11:43 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