Results 1 to 5 of 5
  1. #1
    Amine is offline Novice
    Windows 10 Access 2007
    Join Date
    Nov 2021
    Posts
    8

    Auto resizing forms.

    Hello,
    I found a vba code that is used to resize a form according to the size and resolution of each screen.
    I followed the instructions by changing some parameters on my form and then I placed the vba code and everything works perfectly.
    My problem is that I have 10 forms in my application and it will be better to have a single module that I call by one or two lines on each form instead of pasting all the code on all the forms.

    https://stackoverflow.com/questions/...ic-form-resize



    Any suggestions please?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    That is how this one works I believe?, however you would still need to add a line to each form to call the code?

    https://isladogs.co.uk/automatic-for...g-1/index.html
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Amine is offline Novice
    Windows 10 Access 2007
    Join Date
    Nov 2021
    Posts
    8
    Quote Originally Posted by Welshgasman View Post
    That is how this one works I believe?, however you would still need to add a line to each form to call the code?

    https://isladogs.co.uk/automatic-for...g-1/index.html

    This is not the same code.
    I prefer to use the code I found.
    I just want this code to be in a module and call it on each form.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Haven't spent the time looking at the code and not clear whether you are using all or some of the subs but you can move them to a general module, renaming to a certain extent - for example, the form_load sub would become a function

    Code:
    Public Function frmLoad(frm as form)
         
        fontZoom = 1
        SaveControlPositionsToTags frm
    
    End Function
    
    Then in the form event properties put

    =frmLoad(FORM)

    instead of [Event Procedure]

    or if you use the actual event
    Code:
    Form_Load()
        frmLoad Me
    End Sub
    
    for those subs with parameters you will have to go the second way or use a class module

    the SaveControlPositionsToTags should work unchanged in the new module since it is already declared as public

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You can of course spend time adapting the code you found on StackOverflow but its a far more complex method of achieving the same result as you will get from my code in the link provided in post #2 by @welshgasman.
    If you use my code, you need to import the module modResizeForm to your app and add one line of code ResizeForm Me to the Load event of each form. That's basically all you need to do!

    Your choice.
    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. Replies: 13
    Last Post: 07-14-2020, 02:10 PM
  2. Replies: 2
    Last Post: 10-18-2016, 07:07 AM
  3. Resizing Forms
    By Lou_Reed in forum Access
    Replies: 12
    Last Post: 01-21-2016, 10:40 AM
  4. Resizing forms
    By Lukael in forum Forms
    Replies: 10
    Last Post: 11-11-2015, 12:53 PM
  5. Auto Resizing Grid Control
    By shaferda in forum Forms
    Replies: 1
    Last Post: 02-14-2012, 09:38 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