2 Subform, how to sync ColumnWidth and ColumnOrder

JoeBlack1980
JoeBlack1980 used Ask the Experts™
on
Hi everybody,

In one of my access projects i have a FormA with some subforms.

Let's call Main Form as FormA
Let's call the subforms as FormASubform1 and FormASubform2.

FormASubform1 and FormASubform2 contains exactly same the same controls.

And the controls are like :
FormA!FormASubform1form.form!Control1
FormA!FormASubform1form.form!Control2
FormA!FormASubform1form.form!Control3
and goes on

and in the other

FormA!FormASubform2form.form!Control1
FormA!FormASubform2form.form!Control2
FormA!FormASubform2form.form!Control3
and goes on

So as you can see control names are also identical in each form

They are both in DATASHEET view.

What i want is , when a user change a columnwidth or columnorder or columnvisibilty in FormASubform1 i need FormASubform2 to has exactly the same view.
So it can be a press of a button , or oncurrent event (doesnt really matter) , a vba code which will alter the columns in FormASubform2 .

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
MIS Liason
Most Valuable Expert 2012
Commented:
This syntax works fine for me:

Dim ctl As Control
Dim strCtlName As String
    For Each ctl In Me.subform1.Form.Section(0).Controls
        If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
            strCtlName = ctl.Name
            [subform2].Form(strCtlName).ColumnWidth = [subform1].Form(strCtlName).ColumnWidth
        End If
    Next ctl


Sample attached
Adapt references, names, Sections, Controltypes, ...etc, as needed,
...Have fun!

;-)

JeffCoachman
Access-EEQ26538835SynchronizeDat.mdb

Author

Commented:
Dear Jeff,
This is a fantastic solution,
Thanks
 
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
...and thank you for an interesting and thought provoking Question...

;-)

Jeff

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial