Subform Resize help (1 Viewer)

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
i have a mainform which has a subform.
i am changing my subform dynamically using
Me.objSubform.SourceObject = subformname

i am using a resizing code suggested by ken getz in the form_open event of mainform

on changing screen resolution everything in mainform changes nicely, but subform doesnot changes.

how rectify this or anyone has better approach
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
Does Ken's code change the sizes of the text boxes combo boxes etc?
 

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
yes it does, by the way the i tried something
my subform was not assigned any sourceobject initially so i think it was not resizing it, so i assigned a dummy form to the subform at start and now it is getting re sized to the resolution. but on chaning the subform sourceobject it is not resizing the content of it...strange
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
How are you assigning the form object? Are you using an on load event or something?
 

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
i have a click event in mainform from where i assign subform
Forms![MainForm]![SubFm].SourceObject = "formname"

and in formname form_open event i am again calling resizing code

i noticed !!!
when i pre-assign formname in design mode to the subform and open the main form then everything comes neat and clean..all things in subforms also

but when i am trying to dynamically assign the form to the subform then it is not taking ......
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
It sounds like it's the order of events is the problem.

So I reckon you need to assign the subform before you call Ken Gets code.
 

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
exactly...but where should i put the code
i tried open , load, current of formname
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
In my experience I have had problems with the built-in events like on load, in that some things you expect to happen, don't.

The solution is to build a Public function within the form you are opening, open the form and then call the public function.
 

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
In my experience I have had problems with the built-in events like on load, in that some things you expect to happen, don't.

The solution is to build a Public function within the form you are opening, open the form and then call the public function.

ie what i am looking for..where to put the code....THEN
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
What I suggest you do is build a public function in the form you intend opening. Add a command button to this form, just to test this code. Have this code display a message box. Once you have this working we can attempt to open the form and run the public function.
 

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
did that..no success....

conclusion
works fine : when we set the SourceObject in the subform in design mode

no success : when activated using button/click

but something strange is happening
like when form is maximized and i click button to do resize : nothing happens

but when my form window is small,then
- if i click to load a form to subform and
- click button to do resize and
- maximize window.

subform gets re-sized automatically.

can someone explain why ?
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
I'm getting confused here..... I was under the impression that Ken's code works OK and updating the subform works OK but the problem is getting them to work together?
 

SantoR

Registered User.
Local time
Today, 12:56
Joined
Apr 20, 2015
Messages
38
code works OK - if i pre assign a form to the subform sourceobject

but is not when changing form allocated to subform dynamically through vba.
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:26
Joined
Jul 9, 2003
Messages
16,364
So the solution is to assign the subforms source object before running Ken's code.

I'm assuming you have a main form which I will refer to as the "Calling Form" from which with the agency of command button you are opening another form which I will refer to as the "Called Form" This command button also has the code which assigns the subform.

In the "Called Forms" open event you are running Ken's code.

I think what's happening is Ken's code is running before the assignment of the subform takes place.

If that's the case, then the solution is not to run kenz code from the on open event.

So we create a function which we will use to simulate our own on open event which we can call when we want.

If that's the case then the first step is to create a function in your "called form".

Create a function make it public give it the name fX().

Have it display a message box with the message "hello".

Test it by creating a command button on your "called form".

Once you have it working on your "called form", you need to change the code on your "calling form" to open the "called form", and also run the function fX().

Confirmation that this is working will be when the "called form" opens and the message box also opens saying 'hello".

Now change the fX() function so that instead of calling the message box it calls kens code.
 

Users who are viewing this thread

Top Bottom