Solved Resize columns of an embedded subform

Mario R. Perez

New member
Local time
Today, 02:09
Joined
May 14, 2020
Messages
22
Hi there, I have problems how to resize the columns after selecting an element of a combobox, where "CHILDTYPE" is a embedded subform and "fldname" should be the name of the first column, I think that's where my mistake is.
Thanks for advance.
Happy new Year 2023
Mario Lima Peru
 

Attachments

  • Screenshot 2022-12-31 114826.jpg
    Screenshot 2022-12-31 114826.jpg
    46.7 KB · Views: 104
  • Screenshot 2022-12-31 115113.jpg
    Screenshot 2022-12-31 115113.jpg
    54.6 KB · Views: 101
You can implement a function like this:

For each column you want to resize, put a value in the control's tag property, such as "Fixed".
For each column you want to hide and keep hidden, put a value in the control's tag property, such as "Hidden".

Call this function from the Current Event of the form which needs to resize columns.

Public Function DataSheetControls(ByRef frm As Form) As Variant
'---------------------------------------------------------------------------------------
' Procedure : DataSheetControls
' Author : GPC Data
' Date : 9/25/2010
' Purpose :
'---------------------------------------------------------------------------------------
Dim ctl As control

On Error GoTo errHandler

For Each ctl In frm.Controls
If ctl.Tag = "Hidden" Then
If ctl.ColumnHidden = False Then ctl.ColumnHidden = True
ElseIf ctl.Tag = "Fixed" Then
ctl.ColumnWidth = -2 ' -2 is sets column width to fit displayed text exactly
End If
Next ctl

frm.RowHeight = 0.1667 * 1440' set rows to default height


exitProc:
Exit Function

errHandler:
MsgBox "Error"
Resume CleanUp

End Function
 

Users who are viewing this thread

Back
Top Bottom