locked
Snap Access Application to Specific Monitor w/ VBA RRS feed

  • Question

  • I have a database with a Switchboard in a fixed position using the .move command.   I have it set up this way so that the Switchboard appears "docked" on the left side of the screen, keeping it visible while opening reports, forms, etc.  With my dual monitor setup, I have a button on the Switchboard that will move it back and forth between two predefined positions (ie: position for monitor 1 and position for monitor 2). 

    What I was looking for, but am unable to find, is if there is a way to also move the entire Access App window itself through VBA?  Currently, when I use the "Switch monitors" button on my Switchboard, it moves the Switchboard but then I have to grab the Access App window and drag it to the other monitor and maximize it.  I don't really mind this myself, but I am looking to expand this database out for use by other colleagues and would like to make it as user friendly as possible.

    Thanks in advance if anyone does happen to have a solution!

    Tuesday, May 2, 2017 12:09 PM

All replies

  • Hi,

    You might try using the MoveWindow API.

    Hope it helps...

    Tuesday, May 2, 2017 2:56 PM
  • Something I do occasionally is to use the Switchboard as a main form and maximize it. Then I put a subform on it to take up the unused area. If I need more space I open a form and hide the switchboard, but usually there is plenty of room to load the subform.


    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Tuesday, May 2, 2017 4:35 PM
  • Hi spm5117,

    you can try to check function below which is use to set the postion and size of Access Window.

    Option Compare Database
    Option Explicit
    
    Declare Function GetSystemMetrics32 Lib "user32" _
        Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
    
    Declare Sub SetWindowPos Lib "user32" (ByVal hWnd&, _
    ByVal hWndInsertAfter&, _
    ByVal X&, ByVal Y&, ByVal cX&, _
    ByVal cY&, ByVal wFlags&)
    
    Global Const HWND_TOP = 0 'Moves MS Access window to top
    'of Z-order.
    
    'Values for wFlags.
    
    Global Const SWP_NOZORDER = &H4 'Ignores the hWndInsertAfter.
    
    
    Function SizeAccess(cX As Long, cY As Long, cWidth As Long, cHeight As Long)
    
    Dim h As Long
    'Get handle to Microsoft Access.
    h = Application.hWndAccessApp
    
    'Position Microsoft Access.
    SetWindowPos h, HWND_TOP, cX, cY, cWidth, cHeight, SWP_NOZORDER
    Application.RefreshDatabaseWindow
    End Function
    
    Function ScreenRL(cRight As Boolean)
    
    'pick up the current monitor height and width
    Dim w As Long, h As Long
        w = GetSystemMetrics32(0) ' width in points
        h = GetSystemMetrics32(1) ' height in points
        w = w / 2
        h = h - 30
    
    'set the Access window Size using SizeAccess function
    If cRight = True Then
        'position the access widow to take up the Left half of the desktop
        SizeAccess w, 0, w, h
        Else 
        'position the access widow to take up the Left half of the desktop
        SizeAccess 0, 0, w, h
        End If
    
    
    End Function

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, May 3, 2017 5:43 AM