Resize a control on a continuous form

John Sh

Member
Local time
Tomorrow, 06:04
Joined
Feb 8, 2021
Messages
535
I have code, below, on a single form that resizes a control if the text is longer than the control width, when the control has focus.
Screenshot_44.jpg


Is it possible to do the same thing on a continuous form?
All I can do so far is highlight the entire column.

Code:
Public Sub newSize(str As String)
    Dim cTop As Integer
    Dim Ctrl As Control
    Dim frm  As Form
    Set frm = Screen.ActiveForm
    Set Ctrl = frm.ActiveControl
    nLen = getInt(Len(Nz(Ctrl, "")))
    If str = "UP" And nLen > 1 Then
        cHeight = Ctrl.Height
        cTop = [Ctrl].Top - (cHeight * IIf(nLen > 1, nLen - 1, 1))
        [Ctrl].Top = cTop
        [Ctrl].Height = cHeight * nLen
    ElseIf str = "DN" And Ctrl.Height > 350 Then
        Ctrl.Top = [Ctrl].Top + (cHeight * IIf(nLen > 1, nLen - 1, 1))
        Ctrl.Height = cHeight
    End If
    Set frm = Nothing
    Set Ctrl = Nothing
End Sub

Public Function getInt(n As Double)
    If n > 0 Then
        n = n / 50
        n = IIf(n > Int(n), Int(n + 1), Int(n))
    Else
        n = 1
    End If
    getInt = n
End Function
 
Last edited:
Any property of a control you set in a continuous form affects all rows. What might make more sense is to show the current row in the header or footer, and make it available for editing/formatting/size-changing in that context.
 
Any property of a control you set in a continuous form affects all rows. What might make more sense is to show the current row in the header or footer, and make it available for editing/formatting/size-changing in that context.
Makes a lot of sense. I'll give it a try.
Thank you.
 
Special note, when setting properties for a continuous form, the change affects ALL INSTANCES of the form. Found this out the hard way, but for what I was doing, it was a wonderful way to set the same default value to any other record being changed.
 
Any property of a control you set in a continuous form affects all rows. What might make more sense is to show the current row in the header or footer, and make it available for editing/formatting/size-changing in that context.
Thanks for the suggestion Mark. It works a treat.
John
 

Users who are viewing this thread

Back
Top Bottom