Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176

    Discrepancy between Move command and Window Height

    When using the Me.Move command, I set the Height of the current form to be 2792 pixels - Me.Move <left>, <top>, , 2792
    However in the next line I have put a line to examine the form height - MsgBox Me.WindowHeight.


    This returns a value of 2790 - a minor discrepancy.

    Can anyone give a suggestion as to why this might be ?
    Not a big deal, but it is causing a slight misalignment of a number of forms (Access 2007).

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Actually the values are in twips where 1440 twips = 1 inch.

    Forms use a variety of units for different purposes: twips, pixels & points
    For info, 1 pixel = 15 twips so 96 px = 1 inch and 1 point =20 twips (72 points = 1 inch)

    Anyway, there can be issues with rounding between units plus the need to manage form components whose size is fixed e.g. navigation buttons, title bar height etc
    If you use anywhere in the range 2778-2792, the output will be 2790. 2663-2777 gives 2775 and 2793-2807 gives 2805
    Can you see a pattern here?
    If you want an output value that is EXACTLY what you type, ensure it is divisible exactly by 15

    If you want to know more about form sizes & units & how you can use them to do exactly what you want, see my article Move Forms & Controls - Mendip Data Systems
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    Thanks for your reply.
    Yes, I had meant to say TWIPS not pixels.

    I had forgotten about the rounding issues. I think I have come across that before.
    That's the issue solved then. Will just have to ensure the values are in multiples of 15 or live with the minor misalignment.

  4. #4
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    Actually, issue not resolved. Still getting a gap even when everything is a multiple of 15.
    As I test, I created two simple forms F1 and F2.
    On opening F1, I use Me.Move 3000, 3000, , 3000 (Left, Top, Width, Height)
    On opening F2, I use Me.Move 3000, [Form_F1].WindowTop + [Form_F1].WindowHeight, , 3000

    Would have expected F2 to be immediately below F1, but there is a gap of what looks like about 72 TWIPS.
    Puzzling.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Hi. Only a quick reply as I’m on my phone. Strongly suggest you read my article. See earlier link

  6. #6
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    Yes, I have read your article - very useful and informative that I will use for further reference.

    I could not see anything that would explain the issue I have though. Surely the Windows Height + Windows Top should mean that another form placed at that position (i.e. FT + TH in your diagram) should be immediately below the first, without any visible gap (all multiples of 15).

  7. #7
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    Quote Originally Posted by Miles R View Post
    Yes, I have read your article - very useful and informative that I will use for further reference.

    I could not see anything that would explain the issue I have though. Surely the Windows Height + Windows Top should mean that another form placed at that position (i.e. FT + TH in your diagram) should be immediately below the first, without any visible gap (all multiples of 15).
    Addendum, The only thing I can think of at the moment is that the actual visible form height is slightly less that WindowsHeight.

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    Perchance does this minor misalignment have anything to do with the design grid setting? Mine is always at 24.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    No, I don't think so.

    Actually with further tests with two forms, I believe it is to do with the form Border Style.
    Mine were set to Dialog. If I set them to None, then there is no gap and the actual measurable form height (using ruler on screen) is exactly the same as the WindowHeight. With any other sort of Border Style, the measured height seems to be about 60 TWIPS less than WindowHeight. There seems to be some invisible border (also on the left edge of the form as well).

    Not sure if this is a design feature or a quirk.

    Thanks for all the replies. We live and learn.

  10. #10
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    Probably not a factor, but one thing I learned not too long ago was how Access seems to reserve some space for scroll bars. So even if you set the property to none for horizontal and/or vertical scroll bars and the form window encroaches on the space where a scrollbar would be you end up with a bit of extra space. I think this only applies to certain form border settings and 'none' probably isn't one of them.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    OK I'm back at my computer & have created a quick demo with two forms A & B.
    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	17.2 KB 
ID:	45250

    The code is very simple & I had absolutely no issues getting this to work...first time.

    I made no attempt to fix the sizes in multiples of 15 twips (1 whole pixel)
    In fact you can resize Form A by dragging on its border & the code still works.
    Similarly you can change the border style of Form A (currently sizable) & Form B still lines up directly below it.
    Similarly with scrollbars on or off (currently off on both forms)

    Hopefully you can see differences in what I've done & your own app
    Hope that helps
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    I basically did the same thing, but with different results. There is a gap when border style is Dialog or Thin, no gap if Border Style is None.
    The only thing that I can think is that you are using a newer version of Access, which does not have this quirk. Mine is Access 2007.

    Anyway, not a big deal and I can now resolve it in Access 2007 by making an allowance for the invisible border.

    Thanks.

  13. #13
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Did you check the results using my demo file? If not, please do so. It says 0 views so far!

    I checked my demo in A365 & A2010
    I do have a copy of 2007 on a VM but its not available now.

    However I resaved my demo file as a 2003 MDB file & checked that in A2010
    Results are still perfect

    I'll attach that here so you can check that as well
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  14. #14
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    176
    Thanks for your help. My computer won't let me run your code for security reasons. I'm sure it is OK though.
    It seems that the gap was a bug in Access 2007 which has now been resolved in later versions.
    I'm got a work round that works, so all OK now.
    Thanks again.
    I shall leave this thread.

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    I've just tested my example app in my A2007 VM. It still works absolutely fine no matter what border style is used.
    So I disagree with your comment about there being a bug in A2007 - Sorry but I think its your code.

    As you say you aren't able to look at my code for security reasons, here it is below in full...

    Form A:
    Code:
    Option Compare DatabaseOption Explicit
    
    
    Private Sub cmdClose_Click()
        DoCmd.Close acForm, Me.Name
    End Sub
    
    
    Private Sub cmdOpenB_Click()
        If CurrentProject.AllForms("FormB").IsLoaded Then DoCmd.Close acForm, "FormB"
        DoCmd.OpenForm "FormB"
    End Sub
    Form B:
    Code:
    Option Compare DatabaseOption Explicit
    
    
    Private Sub cmdClose_Click()
        DoCmd.Close
    End Sub
    
    
    Private Sub Form_Load()
    
    
     Dim intTop As Integer, intLeft As Integer
    
    
        If CurrentProject.AllForms("FormA").IsLoaded Then
            'form opens directly below Form A
            intTop = Forms!FormA.WindowTop + Forms!FormA.WindowHeight
            intLeft = Forms!FormA.WindowLeft
            
            DoCmd.MoveSize intLeft, intTop
        Else
            'form opens at top left
            DoCmd.MoveSize 0, 0
        End If
    
    End Sub


    However, perhaps you could manage security by just opening files it in a non-trusted location so the code doesn't run
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. vb to close command window
    By TSSIn in forum Programming
    Replies: 1
    Last Post: 07-22-2020, 06:30 PM
  2. Replies: 2
    Last Post: 02-28-2018, 05:04 PM
  3. Move a command button?
    By 82280zx in forum Forms
    Replies: 2
    Last Post: 06-16-2014, 04:40 PM
  4. Move to next field command...
    By mvolpone in forum Forms
    Replies: 1
    Last Post: 07-06-2010, 09:30 PM
  5. Use fixed height and width for the Access window
    By AndrewAfresh in forum Access
    Replies: 3
    Last Post: 07-05-2006, 09:20 AM

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