Error 2462 - Resizeform Module (1 Viewer)

HillTJ

Registered User.
Local time
Today, 10:57
Joined
Apr 1, 2019
Messages
391
Hi, I've been using the form resize module kindly provided by Colin Riddington (guru) & Jamie Czernik and others on an application. It works well to auto resize my forms to suit varying monitor resolutions. I can swap between a small laptop and a large monitor all good. I have the application 'Calibration' (the latest version has been uploaded to this site under a different thread) installed on a shared network drive & database is not yet split & it works fine. However, I ran it on a different PC that has 32bit access runtime only installed & I get the following error message upon load 'Error 2462 - the section number you entered is invalid'. The code excerpt that causes the error is attached for reference (I did not include the full code).

Any ideas what this means & how to fix?

Code:
Private Sub Resize(sngFactor As Single, frm As Access.Form)

Dim ctl As Access.Control
On Error GoTo ErrorHandler
    'Resize height for each section:
    With frm
        .Width = .Width * sngFactor
       .Section(Access.acHeader).Height = .Section(Access.acHeader).Height * sngFactor
       .Section(Access.acDetail).Height = .Section(Access.acDetail).Height * sngFactor
       .Section(Access.acFooter).Height = .Section(Access.acFooter).Height * sngFactor
    End With
    '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 * sngFactor
                .Left = .Left * sngFactor
                .Top = .Top * sngFactor
                .Width = .Width * sngFactor
                
                'next line moved back to individual control properties below
               ' .FontSize = .FontSize * sngFactor
               ' Enhancement by Myke Myers --------------------------------------->
                'Fix certain combo box, list box and tab control properties:
                Select Case .ControlType
                    Case acLabel, acCommandButton, acTextBox, acToggleButton
                         .FontSize = .FontSize * sngFactor
                    Case acListBox
                         .FontSize = .FontSize * sngFactor
                        .ColumnWidths = AdjustColumnWidths(.ColumnWidths, sngFactor)
                    Case acComboBox
                        .FontSize = .FontSize * sngFactor
                        .ColumnWidths = AdjustColumnWidths(.ColumnWidths, sngFactor)
                        .ListWidth = .ListWidth * sngFactor
                    Case acTabCtl
                        .FontSize = .FontSize * sngFactor
                        .TabFixedWidth = .TabFixedWidth * sngFactor
                        .TabFixedHeight = .TabFixedHeight * sngFactor
                    Case Else  'no other code here
                        'acRectangle, acCheckBox, acImage, acLine, acPageBreak, acSubform
                        'acOptionButton, acOptionGroup, acObjectFrame, acBoundObjectFrame
                End Select
                '------------------------------------> End enhancement by Myke Myers
            End With
        End If
    Next ctl
    
ExitError:
    Exit Sub

ErrorHandler:
  Select Case Err.Number
        Case 999
    Resume Next
        Case 9999
    Resume Next
        Case Else
    Call LogError(Err.Number, Err.Description, "Resize(sngFactor As Single, frm As Access.Form)")
        Resume ExitError
    End Select

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:57
Joined
Oct 29, 2018
Messages
14,819
Hi. Are you able to determine which line was causing the error? Does your form have the header and footer sections displayed?
 

HillTJ

Registered User.
Local time
Today, 10:57
Joined
Apr 1, 2019
Messages
391
theDBguy, thanks for the prompt response. Forms are not missing anything, but sizing is a bit strange (it shows horizontal/vertical scroll bars) on my tabbed mainform & preview of reports extends to a phantom page. I guess this is because the 'resizeform' routine is not working. I could comment out the error trapping routine to find the offending line, but be aware that the PC exhibiting the error only has access runtime installed, so I'd assume that there will be no debug screen? I'll try on an independent PC that I've not run it on before that has a proper Access version installed & see what happens.
 

missinglinq

AWF VIP
Local time
Today, 17:57
Joined
Jun 20, 2003
Messages
6,414
Is not one of the limitations of Access Runtime that it doesn't allow design changes...and is that not the point of the FormResize hack...to resize the Forms?

Linq ;0)>
 

HillTJ

Registered User.
Local time
Today, 10:57
Joined
Apr 1, 2019
Messages
391
missingling, I've used Resizeform on another app & it allows the user to open the app on various PC's with differing resolutions & it scales the forms to suit. Works really well. This is the first time I've tried it on a PC equipped with access runtime only. I don't know whether this is the problem. I was hoping that someone has encountered this?
 

HillTJ

Registered User.
Local time
Today, 10:57
Joined
Apr 1, 2019
Messages
391
OK, did some more research. Monitor that the app was developed on has a screen resolution set @ 1920 x 1080. Monitor of 'Runtime' PC was set the same & displayed the said error. Upon reducing the screen resolution to 1366 x 768, no error! Why, I have no idea!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:57
Joined
Oct 29, 2018
Messages
14,819
OK, did some more research. Monitor that the app was developed on has a screen resolution set @ 1920 x 1080. Monitor of 'Runtime' PC was set the same & displayed the said error. Upon reducing the screen resolution to 1366 x 768, no error! Why, I have no idea!

Hi. I have no clue either but glad to hear you figured it out. Cheers!
 

isladogs

CID VIP
Local time
Today, 22:57
Joined
Jan 14, 2017
Messages
14,729
Hi
Just noticed this thread.

@Terry
Thanks for the compliment which I certainly don't deserve!

I rarely need to use Access runtime but was surprised by your comments about using AFR with runtime. So I decided to check.

I've just re-tested several of my applications which use automatic form resizing on a Windows 7 VM with Access 2010 runtime only. All of them worked perfectly with no errors.

@Linq
The AFR code does not alter the form design. It dynamically scales the form size as well as the position and size of all form objects depending on the monitor size and resolution compared to that it was originally designed in.
 

HillTJ

Registered User.
Local time
Today, 10:57
Joined
Apr 1, 2019
Messages
391
Colin, when I reduced the screen resolution all came good!. I have used the code on another project trouble free. Really strange.
 

isladogs

CID VIP
Local time
Today, 22:57
Joined
Jan 14, 2017
Messages
14,729
My screen resolution used for development work is also 1920*1080.
However I use an 800*600 form template for resizing purposes.
To remind you, that is a form that would occupy the entire screen if displayed in that low resolution.
Without resizing it would therefore occupy around 1/4 of the monitor in form view but full screen with resizing code.

The app I used for the runtime test was created in that setup and tested in a runtime VM on the same machine at the same resolution.

Just as a test, try running my example app from the resizing article on that runtime machine.

If the above is no help, I can't explain your runtime issue.
 

isladogs

CID VIP
Local time
Today, 22:57
Joined
Jan 14, 2017
Messages
14,729
theDBguy, thanks for the prompt response. Forms are not missing anything, but sizing is a bit strange (it shows horizontal/vertical scroll bars) on my tabbed mainform & preview of reports extends to a phantom page. I guess this is because the 'resizeform' routine is not working.

Just read this again.
As mentioned in my website article, tabbed forms can be slightly problematic in AFR.

Those symptoms indicate you are right 'at the limit' with sizing as far as the runtime machine is concerned.
Solve the form issue by reducing the form width and height by a very small amount so that the scrollbars aren't needed. Or set the form scrollbars to Neither.
Solve the report issue by slightly reducing the report width or by reducing the left and right margins of the report

You could also check and slightly modify the value of the constants at the top of the modResize module.
 

Users who are viewing this thread

Top Bottom