Results 1 to 14 of 14
  1. #1
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161

    Navigation Pane Width

    Is there a way to determine the Navigation Pane width from VBA? and an event triggered when the Navigation Pane is closed, opened, resized etc.


    Basically, I want to resize items on my forms if the Navigation Pane is open, based on its width. Have searched and can't find any solution yet.
    Can't believe no-one else has wanted to do this.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    What you want to do will partly depend on whether you are using overlapping windows or tabbed documents
    I have an extended article and example application on my website that you may find useful: Accurately Move Forms & Controls
    In case it helps it also includes code to maximise/minimise/hide the nav pane. Similarly for the ribbon.
    However I've never found a way of successfully setting a specific width for the nav pane in code
    The database documenter will tell you the width but that doesn't provide any method of changing it
    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
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    suggest look at the form insidewidth property and apply in the form resize event. e.g.

    myControl.width=insidewidth-mycontrol.left-57 'to allow a 1mm 'edge'

    insidewidth will also take account of other objects such as scrollbars and recordselectors

    alternatively use the layout properties of the form

  4. #4
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161
    Thanks for that, I will have a look later. I am using overlapping windows. Don't need to maximise/minimise/hide the nav pane from code, just adjust the main form.
    In theory there must be a way to do this, because Access is shifting the forms left or right by the correct amount when the nav pane is opened or closed. May not be possible for the programmer to get at this from within VBA code though.
    p.s. this is only a nice to have, if it is easy to do.

  5. #5
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161
    Thanks for the reply, but I don't think this will help as unless I am mistaken when the Navigation Pane is opened or closed, Form Resize events are not triggered and the insidewidth is not changed. All that happens is the open forms are shifted to the left or right.
    I experimented previously with the Form.left property and it was exactly the same value whether the navigation pane was open or closed. This must be relative to the window Access is allowing for the User Application.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Correct. Form.left and Form.Top are always relative to the application window wherever the size of the nav pane or ribbon.
    As an aside, have you considered automatic form resizing?
    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

  7. #7
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161
    Automatic form resizing would not help in my case as I have complicated vba to accurately place items on my forms. Automatic resizing would just mess that up.
    p.s. as another aside, any idea why when I did test Form.left, it came up with a slightly negative value (-165).

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    perhaps the bit of the form between -165 and 0 is hidden by the nav window?

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I also have complex VBA to accurately place objects on my forms and place forms relative to other forms.
    I also use automatic form resizing on almost all my apps.
    There is no reason why AFR should mess things up though that may depend on what code you have.
    You could have a look at my AFR tutorial http://www.mendipdatasystems.co.uk/a...g-1/4594554784

    Its perfectly possible for the top left of your form to be tucked behind your nav pane or ribbon.
    Or if its a popup it can be moved over one or both items
    If you have dual monitors you can get large negative values by dragging a form onto the secondary monitor.
    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

  10. #10
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161
    OK, thanks I will have to look at this in a bit more details.

  11. #11
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161
    No, don't think so. Just tried with a hidden navigation frame and the number is still negative - 150 TWIPS actually. The form is right at the left of the screen with only a narrow border of maybe 1 or 2 pixels - 15-30 TWIPS. Doesn't really matter though, just curious how it could be negative on a single monitor.
    Thanks anyway.
    Still can't find a way to solve my original problem though. I could probably get the Application Window left position by using an API call using an Access window handle, but not sure if I can get an event triggered if the Navigation window is opened or closed. Not sure if it is worth the effort. Don't like to be beaten though.

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Sorry - didn't understand your comments in the previous reply

    If you look at the example in the link I supplied in post #2 you will see exactly what I mean about negative values being possible for top & left of a form
    e.g. open Form1, drag into top left of app window so its slightly hidden by nav pane and/or ribbon.
    Then click Form Info to view the properties of Form1 as shown below:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	15 
Size:	133.1 KB 
ID:	37931

    Anyway, I think what you are trying to do is unlikely to succeed
    Coming back to your initial question, there are two built in database properties that are relevant here:

    NavPane Closed = 0 when expanded ; 1 when minimized
    NavPane Width = integer value such as 315 = saved value for nav pane width when db opened

    You can see both of these (and more) by selecting Database Documenter in Tools menu.
    Then select Properties in Current Database tab

    Alternatively, the function below will get the value for the 'NavPane Width' property

    Code:
    Function GetNavPaneWidth() As Integer
    
    On Error GoTo Err_Handler
    
        Dim db As DAO.Database
        Dim prp As DAO.Property
        
        Set db = CurrentDb()
        For Each prp In db.Properties
            If prp.Name = "NavPane Width" Then GetNavPaneWidth = prp.Value
        Next
        
        Debug.Print GetNavPaneWidth
        
        Set db = Nothing
        
    Exit_Handler:
        Exit Function
        
    Err_Handler:
        MsgBox "Error " & Err.Number & " in GetNavPaneWidth procedure : " & Err.description, vbCritical, "Program error"
        Resume Exit_Handler
    
    End Function
    NOTE:
    1. The width value shown is not affected by minimising / maximising the nav pane
    2. If you change the width manually, the property value is not updated until you next open the application
    For that reason,I doubt its possible to achieve what you want using VBA
    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

  13. #13
    Miles R is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    161
    Thanks Colin,
    You obviously know your stuff. I could not find the Form Info on Access 2007, so maybe it is in a later edition. Must migrate to Office 365 soon.
    The info about NavPane is useful for future reference, but I don't think I will pursue this because if I can't get an event triggered on Nav Close/Open and get dynamic width of Nav Pane there would be no point. It was only a simple thing I wanted to do, but not worth the effort in the end.
    I will mark this thread closed, if I can figure out how to do that.

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    The form frmFormInfo in the screenshot is part of my example application in the link I gave - its not built into any version of Access.
    However you are welcome to import the form and all related code into your own applications if you wish.
    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

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

Similar Threads

  1. Programming Navigation Pane Width in VBA
    By rick44 in forum Programming
    Replies: 14
    Last Post: 01-15-2019, 03:44 AM
  2. Replies: 2
    Last Post: 04-21-2013, 08:03 AM
  3. Navigation Pane
    By Patrick.Grant01 in forum Programming
    Replies: 11
    Last Post: 01-08-2013, 04:55 PM
  4. Navigation Bar Width Issue
    By RayMilhon in forum Access
    Replies: 4
    Last Post: 07-25-2012, 05:39 PM
  5. Navigation Pane Help Please...
    By Kristena in forum Programming
    Replies: 2
    Last Post: 01-13-2012, 03:03 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