Geoff,
The On open and On load events are firing (sorry about the confusion)
but it's the columnwidth command that's not working for some reason.
Here is the code attached to my subform:
Private Sub Form_Open(Cancel As Integer)
MsgBox Me.parentpart.ColumnWidth
Me![parentpart].ColumnWidth = 5000
MsgBox Me.parentpart.ColumnWidth
End Sub
Both MsgBox's display the same columnwidth (in this case 1120). If the
columnwidth command was working correctly the second Msgbox should
display 5000, but it isn't. And no columns are frozen either. What's
wierd is that this same type logic works in another Access application
I have so there must be some setting somewhere I'm missing?
Regards, Brian
Correction:
Paragraph 2 of my previous post should have said that, when the
"SubForm/SubReport" control contains a sub form, the Object Source
property
of the control is the name of the subform, eg "frmFormName", not
"TableName". Hope that didn't throw you!
Geoff
Brian:
If you created the main form using the AutoForm toolbar icon, then the
subform control's Source Object property will contain something like
"Table.TableName". In this case the subform control is still a
"SubForm/SubReport" control, but it contains a direct reference to the
table. If you open the main form in design view and double-click the
subform control, the table will open in design view. In this case,
there
is no Open or Load events for the "SubForm" when the main form is
opened.
In contrast, if you create a subform yourself and drag it to the design
surface of the main form, then the subform control's Source Object
property will contain something like "TableName". In this case the
subform
control is also a "SubForm/SubReport" control but now Open and Load
events
for the subform will fire when the main form is opened.
Perhaps you've created a subform but didn't drag it to the main form in
design view. This can lead to confusion because, when you open the main
form in normal view, to all intents and purposes the subform may look
like
the subform you created but in fact it may not be. I can't think why
else
the subform's Open and Load events wouldn't fire.
Double-check that your main form really contains the subform you
created.
Regards
Geoff
I have added VBA code in my application to set the columnwidth on a
field in my subform but it won't take, it's like the widths are
frozen.
If I display the field width both before and after the columnwidth
statement the width stays the same. I have put this logic in the
subform Load and Open events. This same logic works in another Access
application I have but not this one. I can't seem to find what I am
doing wrong, any ideas?