Results 1 to 16 of 16

Thread: In Access, resize size application to size form

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    In Access, resize size application to size form

    Hello,

    I'm using Access.

    I want to specify the size of the application (Access) to be adapted with the size of a form (which dimensions can't be changed) and i want the form to be anchored on the top left of the application. I thought to put the code in the Form_load.

    I found a lot of threads that deal with resizing but all of them seem to answer the problem 'size of the controls' with 'size of the form'.

    If someone can help me !

    Thanks by advance.

  2. #2
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: In Access, resize size application to size form

    Hey le highlander:

    I am not exactly sure if I understand what it is you want to do, but it sounds like you want the form to appear in a certain area of the screen when you run your application and also to have all your controls appear in a certain area on the form.

    If, for example, you want to application to fill the entire screen you would use the WindowState property. This can be set at design time or at run time. At design time just select WindowState in the properties window and select either 0-normal, 1, minimized, or 2, maximized. You can also do this with code in the form load event as you stated. Just use WindowState = 2 or whichever choice (0 - 2) that you desire.

    If you want to make your form appear in a certain area on the screen you can use code in the form load event such as: Me.Move 2700, 3000

    The 2700 is the distance from the left side of the screen and the 3000 is the distance from the top of the screen (assuming you set the WindowState property to 2-Maximized). This in in pixels. You can play around with the numbers until you get a feel for it and adjust the numbers according to where you want your form to appear.

    If you want to make your controls appear in a certain location on your form, you do much the same thing. To do this you can set the left and top properties for each control in reference to your form. Again this can be done through the properties windows or in your code.

    I hope this helped.

    Good Luck

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    Re: In Access, resize size application to size form

    hello

    Thanks for your response.
    When i read what you wrote, it seems to be what i want. But it doesn't work when i put it in the form_load (Me.Move ....). Is says 'Compilation Error'.

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: In Access, resize size application to size form

    Don't you want ACESS to line up with a VB form?

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    Re: In Access, resize size application to size form

    yes it's what i want

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: In Access, resize size application to size form

    Moved to Office Development forum.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    Re: In Access, resize size application to size form

    sorry to have put the thread at the wrong place

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: In Access, resize size application to size form

    Its not a problem. It takes members a while to get a feel for the Forums and where their threads are best suited.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: In Access, resize size application to size form

    Not what you want, but why not just size the form with Access as maximized. It pseudo-hides Access behind the form.

    VB Code:
    1. Private Sub Form_Load()
    2.     DoCmd.Maximize
    3. End Sub

    Or you can make Access hidden while the form is shown. Probably less code required with these two manners, but the latter requires some api.

    Also, the MoveSize Command:
    VB Code:
    1. Private Sub Form_Load()
    2.     Application.DoCmd.MoveSize 100, 5, 5000, 5000
    3. End Sub
    Justin Labenne
    www.jlxl.net

  10. #10

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    Re: In Access, resize size application to size form

    The MoveSize command was very useful ! Is there a way to size the Access window ?

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: In Access, resize size application to size form

    You would probably have to use some APIs to resize the main app window as it only allows for the 3 window states and doesnt ahve a size window property or method.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: In Access, resize size application to size form

    This should resize the mailn application window to what ever size you need.
    VB Code:
    1. Option Explicit
    2. Option Compare Database
    3.  
    4. Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
    5. ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    6.  
    7. Private Sub ResizeApp()
    8.     'Resize main app window to 700 high x 1000 wide
    9.     'x and y are the orgin of the top/let corner
    10.     'cx and cy are the size of the window.
    11.     Application.RunCommand (acCmdAppRestore)
    12.     SetWindowPos Application.hWndAccessApp, 0, 0, 0, 700, 1000, 0
    13. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    Re: In Access, resize size application to size form

    ohhhhhhh it's beautiful !

    thanks a lot.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: In Access, resize size application to size form

    Finally, someone that appreciates the true beauty of my code! Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: In Access, resize size application to size form

    Can't say I have ever resized the app window to meet the form window (usually the other way around) very nice code RobDog888.
    Justin Labenne
    www.jlxl.net

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: In Access, resize size application to size form

    Thanks Justin. I too usually do it the other way around but have used this code before on VB6 forms for various things. I never thought t would work for this but Access is also just a regular MDI window so I guess its logical.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width