Question

Hiding Header and resizing Form

Asked by: kfschaefer1

I need to resize a form to fit a Laptop screen - I also have a button that hides and shows the header of the form.  The form contains multiple subforms and a Tab Pages.  I am able to resize and hide the header, except when I try to reset the form to display the Header the tab Pages size will not change to the correct setting. See '<<<<<<<  
The screen resolution is set to 1024X768.

When I step thru the code the Me.TabSub height = 7980 when I need it rest to fit the 1024X768 screen the Detail section is approx 3-4 inches.

Do you know when it will not reset?

K

Private Sub cmdShowHdr_Click()
  DoCmd.Maximize
    Me.Section(acHeader).Visible = Not Me.Section(acHeader).Visible
    If Me.Section(acHeader).Visible = True Then
        Me.SUB1.Height = 4200
        Me.TabSub.Height = 4320'<<<<<<<
        Me.Sub2.Height = 4200
        Me.Sub3.Height = 4200
        Me.sub4.Height = 4200 '7400
        Me.cmdShowHdr.Caption = "Hide"
    Else
        Me.SUB1.Height = 7400 '11500
        Me.TabSub.Height = 7300
        Me.Sub2.Height = 7400 '11500
        Me.Sub3.Height = 7400 '11500
        Me.sub4.Height = 7400 '11500
        Me.cmdShowHdr.Caption = "Show"
    End If
End Sub

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-15 at 09:07:31ID24655305
Tags

Access 2003

Topics

Access Forms

,

Access Coding/Macros

Participating Experts
2
Points
500
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Resize column in subform at runtime
    How do I resize the column width in a subform at runtime?
  2. Resizing
    I've got an image that is 300 pixels/inch. I need to insert another image (72 pixels/inch) into it. When I do so, the inserted image is a bit too small. So, I'll have to resize it a bit larger. Is it better to resize the 72 resolution first, then insert it in the 300? O...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: boag2000Posted on 2009-08-15 at 21:09:06ID: 25107766

You can certainly buy a screen resizer to resize the form.
But this is not the solution in all cases.

We can't really diagnose a "Graphical" issue buy seeing the code.

Can you post a screenshot of this form in a Normal screen as it fits OK in.
Then post a screenshot of this form on the Laptop as it does not fit in.

There may very well be a way to design the form so it does fit.

 

by: bobby6055Posted on 2009-08-16 at 04:01:09ID: 25108534

kfschaefer1:
The code in "code snippet" should do what you wanted. I preset it to 1024 x 768 for you. It should work for you. The code can be downloaded from:

http://www.jamiessoftware.tk/downloads.html

Note:
Simply place the code into a standard module
....and call the code from an "On Load Event" of your form.... as shown below:

Private Sub Form_Load()
 ResizeForm Me!
End Sub

'---------------------------------------------------------------------------------------
' Module    : modResizeForm
' Author    : Jamie Czernik BSc {jamie@jamiessoftware.tk}
' Purpose   : Resizes Microsoft Access forms to fit the current screen resolution.
' Use       : Work on a back-up copy of your application first.
'             Change the constant DESIGN_HORZRES to the horizontal screen resolution
'             used when forms were designed. Change the constant DESIGN_VERTRES to the
'             vertical screen resolution used when forms were designed.
'             Change DESIGN_PIXELS to the DPI used if required.
'             Call ResizeForm Me on the onLoad event for each form (even sub forms).
' Bugs:     : Tab controls and Option Groups are very difficult to handle - see comments
'             throughout code for more information. Scaling forms up works much better
'             than trying to scale forms down. Scaling down will probably distrot fronts.
'             FIX:- Redesign forms to fit lowest resoltion and scale up instead.
'             Continuous sub forms generate random crashes in Access 2002 & later - no fix.
'             Send bug reports to: jamie@jamiessoftware.tk for future fixes.
'             (No immediate support is provided. *Please* check online help, message board
'             and latest version at http://www.jamiessoftware.tk before sending bug reports)
' Test:       Test your application at each possible screen resolution after installing.
' Please    : Consider donating $5 or $10 if you find this code useful by visiting:-
'             http://jamiessoftware.tk/resizeform/rf_download.html
' Credits   : This modResizeForm module was created by Jamie Czernik
'             Contains improvement suggestions/updates from:  Dr. Martin Dumskyj,
'             Nathan Carroll, Wilfrid Underwood & Kyle Hughes.
'             Contains enhancements which fixed some problems in combo boxes, list
'             boxes, and tab controls from: Myke Myers & Chris Garland.
' Updated   : April 2006.
'---------------------------------------------------------------------------------------
Option Compare Database
Option Explicit
'-----------------------------MODULE CONSTANTS & VARIABLES------------------------------
Private Const DESIGN_HORZRES As Long = 1024   '<- CHANGE THIS VALUE TO THE RESOLUTION
                                                'YOU DESIGNED YOUR FORMS IN.
                                                '(e.g. 800 X 600 -> 800)
Private Const DESIGN_VERTRES As Long = 768  '<- CHANGE THIS VALUE TO THE RESOLUTION
                                                'YOU DESIGNED YOUR FORMS IN.
                                                '(e.g. 800 X 600 -> 600)
Private Const DESIGN_PIXELS As Long = 96        '<- CHANGE THIS VALUE TO THE DPI
                                                'SETTING YOU DESIGNED YOUR FORMS IN.
                                                '(If in doubt do not alter the
                                                'DESIGN_PIXELS setting as most
                                                'systems use 96 dpi.)
Private Const WM_HORZRES As Long = 8
Private Const WM_VERTRES As Long = 10
Private Const WM_LOGPIXELSX As Long = 88
Private Const TITLEBAR_PIXELS As Long = 18
Private Const COMMANDBAR_PIXELS As Long = 26
Private Const COMMANDBAR_LEFT As Long = 0
Private Const COMMANDBAR_TOP As Long = 1
Private OrigWindow As tWindow                   'Module level variable holds the
                                                'original window dimensions before
                                                'resize.
 
Private Type tRect
    left As Long
    Top As Long
    right As Long
    bottom As Long
End Type
 
Private Type tDisplay
    Height As Long
    Width As Long
    DPI As Long
End Type
 
Private Type tWindow
    Height As Long
    Width As Long
End Type
 
Private Type tControl
    Name As String
    Height As Long
    Width As Long
    Top As Long
    left As Long
End Type
'-------------------------- END MODULE CONSTANTS & VARIABLES----------------------------
 
'------------------------------------API DECLARATIONS-----------------------------------
Private Declare Function WM_apiGetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
 
Private Declare Function WM_apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" _
() As Long
 
Private Declare Function WM_apiGetDC Lib "user32" Alias "GetDC" _
(ByVal hwnd As Long) As Long
 
Private Declare Function WM_apiReleaseDC Lib "user32" Alias "ReleaseDC" _
(ByVal hwnd As Long, ByVal hdc As Long) As Long
 
Private Declare Function WM_apiGetWindowRect Lib "user32.dll" Alias "GetWindowRect" _
(ByVal hwnd As Long, lpRect As tRect) As Long
 
Private Declare Function WM_apiMoveWindow Lib "user32.dll" Alias "MoveWindow" _
(ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
 
Private Declare Function WM_apiIsZoomed Lib "user32.dll" Alias "IsZoomed" _
(ByVal hwnd As Long) As Long
'--------------------------------- END API DECLARATIONS----------------------------------
 
'---------------------------------------------------------------------------------------
' Procedure : getScreenResolution
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Function returns the current height, width and dpi.
'---------------------------------------------------------------------------------------
Private Function getScreenResolution() As tDisplay
 
Dim hDCcaps As Long
Dim lngRtn As Long
 
On Error Resume Next
 
    'API call get current resolution:-
    hDCcaps = WM_apiGetDC(0) 'Get display context for desktop (hwnd = 0).
    With getScreenResolution
        .Height = WM_apiGetDeviceCaps(hDCcaps, WM_VERTRES)
        .Width = WM_apiGetDeviceCaps(hDCcaps, WM_HORZRES)
        .DPI = WM_apiGetDeviceCaps(hDCcaps, WM_LOGPIXELSX)
    End With
    lngRtn = WM_apiReleaseDC(0, hDCcaps) 'Release display context.
    
End Function
 
'---------------------------------------------------------------------------------------
' Procedure : getFactor
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Function returns the value that the form's/control's height, width, top &
'             left should be multiplied by to fit the current screen resolution.
'---------------------------------------------------------------------------------------
Private Function getFactor(blnVert As Boolean) As Single
 
Dim sngFactorP As Single
 
On Error Resume Next
 
    If getScreenResolution.DPI <> 0 Then
        sngFactorP = DESIGN_PIXELS / getScreenResolution.DPI
    Else
        sngFactorP = 1 'Error with dpi reported so assume 96 dpi.
    End If
    If blnVert Then 'return vertical resolution.
        getFactor = (getScreenResolution.Height / DESIGN_VERTRES) * sngFactorP
    Else 'return horizontal resolution.
        getFactor = (getScreenResolution.Width / DESIGN_HORZRES) * sngFactorP
    End If
    
End Function
 
'---------------------------------------------------------------------------------------
' Procedure : ReSizeForm
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Routine should be called on a form's onOpen or onLoad event.
'---------------------------------------------------------------------------------------
Public Sub ReSizeForm(ByVal frm As Access.Form)
 
Dim rectWindow As tRect
Dim lngWidth As Long
Dim lngHeight As Long
Dim sngVertFactor As Single
Dim sngHorzFactor As Single
Dim sngFontFactor As Single
 
On Error Resume Next
 
    sngVertFactor = getFactor(True)  'Local function returns vertical size change.
    sngHorzFactor = getFactor(False)  'Local function returns horizontal size change.
    'Choose lowest factor for resizing fonts:-
    sngFontFactor = VBA.IIf(sngHorzFactor < sngVertFactor, sngHorzFactor, sngVertFactor)
    Resize sngVertFactor, sngHorzFactor, sngFontFactor, frm 'Local procedure to resize form sections & controls.
    If WM_apiIsZoomed(frm.hwnd) = 0 Then 'Don't change window settings for max'd form.
        Access.DoCmd.RunCommand acCmdAppMaximize 'Maximize the Access Window.
        'Store for dimensions in rectWindow:-
        Call WM_apiGetWindowRect(frm.hwnd, rectWindow)
        'Calculate and store form height and width in local variables:-
        With rectWindow
            lngWidth = .right - .left
            lngHeight = .bottom - .Top
        End With
        'Resize the form window as required (don't resize this for sub forms):-
        If frm.Parent.Name = VBA.vbNullString Then
            Call WM_apiMoveWindow(frm.hwnd, ((getScreenResolution.Width - _
            (sngHorzFactor * lngWidth)) / 2) - getLeftOffset, _
            ((getScreenResolution.Height - (sngVertFactor * lngHeight)) / 2) - _
            getTopOffset, lngWidth * sngHorzFactor, lngHeight * sngVertFactor, 1)
        End If
    End If
    Set frm = Nothing 'Free up resources.
    
End Sub
 
'---------------------------------------------------------------------------------------
' Procedure : Resize
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Routine re-scales the form sections and controls.
'---------------------------------------------------------------------------------------
Private Sub Resize(sngVertFactor As Single, sngHorzFactor As Single, sngFontFactor As _
Single, ByVal frm As Access.Form)
 
Dim ctl As Access.Control            'Form control variable.
Dim arrCtls() As tControl            'Array of Tab and Option Group control properties.
Dim lngI As Long                     'Loop counter.
Dim lngJ As Long                     'Loop counter.
Dim lngWidth As Long                 'Stores form's new width.
Dim lngHeaderHeight As Long          'Stores header's new height.
Dim lngDetailHeight As Long          'Stores detail's new height.
Dim lngFooterHeight As Long          'Stores footer's new height.
Dim blnHeaderVisible As Boolean      'True if form header visible before resize.
Dim blnDetailVisible As Boolean      'True if form detail visible before resize.
Dim blnFooterVisible As Boolean      'True if form footer visible before resize.
Const FORM_MAX As Long = 31680       'Maximum possible form width & section height.
 
On Error Resume Next
    
    With frm
        .Painting = False 'Turn off form painting.
        'Calculate form's new with and section heights and store in local variables
        'for later use:-
        lngWidth = .Width * sngHorzFactor
        lngHeaderHeight = .Section(Access.acHeader).Height * sngVertFactor
        lngDetailHeight = .Section(Access.acDetail).Height * sngVertFactor
        lngFooterHeight = .Section(Access.acFooter).Height * sngVertFactor
        'Now maximize the form's width and height while controls are being resized:-
        .Width = FORM_MAX
        .Section(Access.acHeader).Height = FORM_MAX
        .Section(Access.acDetail).Height = FORM_MAX
        .Section(Access.acFooter).Height = FORM_MAX
        'Hiding form sections during resize prevents invalid page fault after
        'resizing column widths for list boxes on forms with a header/footer:-
        blnHeaderVisible = .Section(Access.acHeader).Visible
        blnDetailVisible = .Section(Access.acDetail).Visible
        blnFooterVisible = .Section(Access.acFooter).Visible
        .Section(Access.acHeader).Visible = False
        .Section(Access.acDetail).Visible = False
        .Section(Access.acFooter).Visible = False
    End With
    'Resize array to hold 1 element:-
    ReDim arrCtls(0)
    'Gather properties for Tabs and Option Groups to recify height/width problems:-
    For Each ctl In frm.Controls
        If ((ctl.ControlType = Access.acTabCtl) Or _
        (ctl.ControlType = Access.acOptionGroup)) Then
            With arrCtls(lngI)
                .Name = ctl.Name
                .Height = ctl.Height
                .Width = ctl.Width
                .Top = ctl.Top
                .left = ctl.left
            End With
            lngI = lngI + 1
            ReDim Preserve arrCtls(lngI) 'Increase the size of the array.
        End If
    Next ctl
    'Resize and locate each control:-
    For Each ctl In frm.Controls
        If ctl.ControlType <> Access.acPage Then 'Ignore pages in Tab controls.
            With ctl
                .Height = .Height * sngVertFactor
                .left = .left * sngHorzFactor
                .Top = .Top * sngVertFactor
                .Width = .Width * sngHorzFactor
                .FontSize = .FontSize * sngFontFactor
                'Enhancement by Myke Myers --------------------------------------->
                'Fix certain Combo Box, List Box and Tab control properties:-
                Select Case .ControlType
                    Case Access.acListBox
                        .ColumnWidths = adjustColumnWidths(.ColumnWidths, sngHorzFactor)
                    Case Access.acComboBox
                        .ColumnWidths = adjustColumnWidths(.ColumnWidths, sngHorzFactor)
                        .ListWidth = .ListWidth * sngHorzFactor
                    Case Access.acTabCtl
                        .TabFixedWidth = .TabFixedWidth * sngHorzFactor
                        .TabFixedHeight = .TabFixedHeight * sngVertFactor
                End Select
                '------------------------------------> End enhancement by Myke Myers.
            End With
        End If
    Next ctl
    '********************************************************
    '* Note if scaling form up: If Tab controls or Option   *
    '* Groups are too near the bottom or right side of the  *
    '* form they WILL distort due to the way that Access    *
    '* keeps the child controls within the control frame.   *
    '* Try moving these controls left or up if possible.    *
    '* The opposite is true for scaling down so in this     *
    '* case try moving these controls right or down.        *
    '********************************************************
    'Now try to rectify Tabs and Option Groups height/widths:-
    For lngJ = 0 To lngI
        With frm.Controls.Item(arrCtls(lngJ).Name)
            .left = arrCtls(lngJ).left * sngHorzFactor
            .Top = arrCtls(lngJ).Top * sngVertFactor
            .Height = arrCtls(lngJ).Height * sngVertFactor
            .Width = arrCtls(lngJ).Width * sngHorzFactor
        End With
    Next lngJ
    'Now resize height for each section and form width using stored values:-
    With frm
        .Width = lngWidth
        .Section(Access.acHeader).Height = lngHeaderHeight
        .Section(Access.acDetail).Height = lngDetailHeight
        .Section(Access.acFooter).Height = lngFooterHeight
        'Now unhide form sections:-
        .Section(Access.acHeader).Visible = blnHeaderVisible
        .Section(Access.acDetail).Visible = blnDetailVisible
        .Section(Access.acFooter).Visible = blnFooterVisible
        .Painting = True 'Turn form painting on.
    End With
    Erase arrCtls 'Destory array.
    Set ctl = Nothing 'Free up resources.
 
End Sub
 
'---------------------------------------------------------------------------------------
' Procedure : getTopOffset
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Function returns the total size in pixels of menu/toolbars at the top of
'             the Access window allowing the form to be positioned in the centre of the
'             screen.
'---------------------------------------------------------------------------------------
Private Function getTopOffset() As Long
 
Dim cmdBar As Object
Dim lngI As Long
 
On Error GoTo err
 
     For Each cmdBar In Application.CommandBars
        If ((cmdBar.Visible = True) And (cmdBar.Position = COMMANDBAR_TOP)) Then
            lngI = lngI + 1
        End If
     Next cmdBar
     getTopOffset = (TITLEBAR_PIXELS + (lngI * COMMANDBAR_PIXELS))
 
exit_fun:
    Exit Function
    
err:
    'Assume only 1 visible command bar plus the title bar:
    getTopOffset = TITLEBAR_PIXELS + COMMANDBAR_PIXELS
    Resume exit_fun
     
End Function
 
'---------------------------------------------------------------------------------------
' Procedure : getLeftOffset
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Function returns the total size in pixels of menu/toolbars at the left of
'             the Access window allowing the form to be positioned in the centre of the
'             screen.
'---------------------------------------------------------------------------------------
Private Function getLeftOffset() As Long
 
Dim cmdBar As Object
Dim lngI As Long
 
On Error GoTo err
 
     For Each cmdBar In Application.CommandBars
        If ((cmdBar.Visible = True) And (cmdBar.Position = COMMANDBAR_LEFT)) Then
            lngI = lngI + 1
        End If
     Next cmdBar
     getLeftOffset = (lngI * COMMANDBAR_PIXELS)
 
exit_fun:
    Exit Function
    
err:
    'Assume no visible command bars:-
    getLeftOffset = 0
    Resume exit_fun
     
End Function
 
'---------------------------------------------------------------------------------------
' Procedure : adjustColumnWidths
' DateTime  : 27/01/2003
' Author    : Myke Myers [Split() replacement for Access 97 by Jamie Czernik]
' Purpose   : Adjusts column widths for list boxes and combo boxes.
' Called By : modResize/Resize().
' Event Modification Information:
'   1. Chris Garland    02/07/2006
'   The event was modified to check if there is any column size entry, and if not, the
'   property is left blank on the control.
'---------------------------------------------------------------------------------------
Private Function adjustColumnWidths(strColumnWidths As String, sngFactor As Single) As String
On Error GoTo Err_adjustColumnWidths
 
Dim astrColumnWidths() As String                'Array to hold the individual column widths
Dim strTemp As String                           'Holds the recombined columnwidths string
Dim lngI As Long                                'For Loop counter
Dim lngJ As Long                                'Columnwidths counter
 
    'Get the column widths:-
    'THIS CODE BY JAMIE CZERNIK------------------------------------------->
    'Replace the Split() function as not available in Access 97:
    'Sets the array to one entry.
    ReDim astrColumnWidths(0)
    'Loops through each character in the Column Widths String passed in by the calling code.
    For lngI = 1 To VBA.Len(strColumnWidths)
        'Looks for each semicolon, which is what separates the individual Column Widths.
        Select Case VBA.Mid(strColumnWidths, lngI, 1)
            'If a semicolon is not found, the character is added to the any characters
            ' already in the columnwidths entry in the array.  If it is found, the
            ' Columnwidths Counter is incremented by one and the array is increased by
            ' one while retaining entered data so that the next columnwidth can be entered.
            Case Is <> ";"
                astrColumnWidths(lngJ) = astrColumnWidths(lngJ) & VBA.Mid( _
                strColumnWidths, lngI, 1)
            Case ";"
                lngJ = lngJ + 1
                ReDim Preserve astrColumnWidths(lngJ) 'Resize the array.
        End Select
    Next lngI
    'Resets the loop counter to 0.
    lngI = 0
    '--------------------------------------------> END CODE BY JAMIE CZERNIK.
    'Access 2000/2002 users can uncomment the line below and remove the split() code
    'replacement above.
    'astrColumnWidths = Split(strColumnWidths, ";")'Available in Access 2000/2002 only
    strTemp = VBA.vbNullString 'Sets the temp variable to a null string
    'Loops through the all the columnwidths in the array, converting them to the new sizes
    ' (using the Width Size Conversion Factor that was passed-in), and recombining them
    ' into a single string to pass back to the calling code. (If there is no Column Width,
    ' the value is left blank.)
    Do Until lngI > UBound(astrColumnWidths)
        If Not IsNull(astrColumnWidths(lngI)) And astrColumnWidths(lngI) <> "" Then
            strTemp = strTemp & CSng(astrColumnWidths(lngI)) * sngFactor & ";"
        End If
        lngI = lngI + 1
    Loop
    'Returns the combined columnwidths string to the calling code.
    adjustColumnWidths = strTemp
    Erase astrColumnWidths 'Destroy array.
    
Exit_adjustColumnWidths:
    On Error Resume Next
    Exit Function
 
Err_adjustColumnWidths:
    Erase astrColumnWidths 'Destroy array.
    Resume Exit_adjustColumnWidths
    
End Function
 
'---------------------------------------------------------------------------------------
' Procedure : getOrigWindow
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Routine stores the original window dimensions before resizing call it
'             when form loads. (before calling ResizeForm Me!).
'             Call it: Form_Load()
'             [More info in "Important Points" - point 5 - in help file.]
'---------------------------------------------------------------------------------------
Public Sub getOrigWindow(frm As Access.Form)
 
On Error Resume Next
 
    OrigWindow.Height = frm.WindowHeight
    OrigWindow.Width = frm.WindowWidth
 
End Sub
 
'---------------------------------------------------------------------------------------
' Procedure : RestoreWindow
' DateTime  : 27/01/2003
' Author    : Jamie Czernik
' Purpose   : Routine restores the original window dimensions call it when form closes.
'             Call it: Form_Close()
'             [More info in "Important Points" - point 5 - in help file.]
'---------------------------------------------------------------------------------------
Public Sub RestoreWindow()
 
On Error Resume Next
 
    Access.DoCmd.MoveSize , , OrigWindow.Width, OrigWindow.Height
    Access.DoCmd.Save
    
End Sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:

Select allOpen in new window

 

by: kfschaefer1Posted on 2009-08-16 at 08:26:27ID: 25109254

How do I reset the size depending of the screen resolution - The difference from a External Monitor and a laptop monitor?

Thanks for code, however, this is only part of what I am looking for.

I am still need a solution for the hide/show of the Form Header and the resizing of objects (Tab Page) from tall to small based on whether the header is visible.

Here are some screen shots
1.  Show screen before :Hiding header- note size of Tab Control.
2.  On Click of HIDE button - Header is hidden and the Tab Control is resized correctly
3.  On Click of Show button - Header is visible, sub forms reisze correctly, however the Tab Control does not resize correctly - Note the scroll bar to the right, indicating there is more to see then what is on the screen.
4.  Tab Control remains the larger size.

It is number 4 I am having issue with why won't the Tab control resize.

Thanks,

K

 

by: boag2000Posted on 2009-08-16 at 12:52:20ID: 25110189

Not sure, Perhaps you will have to dig into an API call to do this:
Pseudo code:

If ScreenResolution=abc X def then
    Hide Something
ElseIf ScreenResolution=ghi X jkl then
    Show Something
End if

But the most straightforward solution may be to redesign the form to work reasonably well for all Resolutions.
The issue here is that what happens when you get a new laptop with different resolutions?
What happens when the user changes the resolution manually on either machine?
What heppens whn more info is added or removed from the form?

Another option would be to make this two (or more) separate forms.

Or even to move some of the info in this "Mega-Form" to pop-up forms ("Click here to view...")

JeffCoachman

 

by: kfschaefer1Posted on 2009-08-16 at 13:15:11ID: 25110288

Its not the resizing of the form per resolution anymore, I went with two separate forms,  

the issue I am having is the hiding of the Form Header and the resizing of the controls and objects to fill the form - giving the user more visible work space.  It is when they want tor see the header again that the Tab control will not resize back to the smaller size.  For some reason the Tab control wants to stay at the maximum size.  However, if the form is closed then reopened it resets the Tab control the correct size if the header is visible.  Not sure where to go from here.

Thanks for your input.

Karn

 

by: boag2000Posted on 2009-08-16 at 13:53:45ID: 25110441

In these case I just have a "Show/hide" button on the form.

Yes there are several post regarding the way tabbed controls display on a form.
No easy answer here...

Instead of jerking around with trying to do it automatically based on the resolution.

Please remember that Tabbed forms were designed to be a way to break a single large set of data into smaller pieces.
For example: a "HouseDetails" record with 50 Fields, broken into Architecture, Aesthetic, Electrical, Mechanical, Plumbing, ...etc.

Developers have since started using them to display Subforms, swap the reordsources, swap subform objects, Related data, unrelated data, ...etc.

So bear in mind that the more complex you make your Tabbed control, the more difficult it will be to control.

There are many factors that affect this:
The size of the tabbed control in relation to its container object, Scroll bar settings, form Border as sizing options, ...etc
(Access 2007's additional settings, complicate this even more.)

It is always best to keep your interface as simple as possible, thus avoiding hard to diagnose situations like this.

;-)

JeffCoachman

 

by: kfschaefer1Posted on 2009-08-17 at 13:47:41ID: 25118248

I got my answer and it was so simple,  thanks Jeff for the assistance.

Solution:

The height of a tab page can't be less than the tallest subform. It appears you are trying to change the size of the page first, then change the height of the various subforms. I suggest you change all the subforms first, and then adjust the size of the tab page.

 

by: bobby6055Posted on 2009-08-17 at 15:04:26ID: 25118821

kfschaefer1:
Please provide link to the outside link where you received assistance so that future EE members can benefit from it.

I also noted that you are not being fair here. JeffCoachman and I deserve to be awarded for the efforts made in helping you here.

At least you acknowledge under ID: 25109254 - ..when you made this statement under ID 25109254 .......
"......Thanks for code, however, this is only part of what I am looking for...."

Your comment was made after I posted the above code under ID: 25108534.

Even if your received assistance somewhere else.....it is in addition to the assistance you already received here....and it should be acknowledged and rewarded accordingly.

Experts dont get paid for assisting EE members but it is good if members like you can at least acknowledge the efforts made by the experts.

Bobby

 

by: bobby6055Posted on 2009-08-17 at 18:02:28ID: 25119519

Karn:
The good thing is that you did the right thing by awarding points ...far better than your previous "request attention" to reward only yourself.

In the future always remember to credit experts for their efforts.


Cheers

Bobby.

 

by: boag2000Posted on 2009-08-17 at 23:34:09ID: 25120550

bobby6055,

Karen has been a member here for about as long as I have, (about 5 years) she is well aware of the rules of the site and is generally fair with regard to assigning points/Credit.
(You can check her profile for proof of this:
http://www.experts-exchange.com/M_3481841.html)

If she did not give the proper credit, it was probably an oversight.
;-)

JeffCoachman


 

by: bobby6055Posted on 2009-08-18 at 03:31:19ID: 25121637

Jeff:
Okay - It may be an oversight as you've rightly stated.

A reminder is never too much.

Cheers

 

by: bobby6055Posted on 2009-08-18 at 03:45:55ID: 25121711


As you've rightly suggested earlier in this thread ID 25110189
"...Perhaps you will have to dig into an API call to do this..."

You may right with the "API call" as I stumbled on two API Calls that may be just right for this topic....in addition to the Form Resizer Code that I suggested earlier..."

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...