Assign a Subform's Height Remotely

M_S_Jones

Registered User.
Local time
Today, 20:16
Joined
Jan 4, 2008
Messages
119
I'm trying to change the height of a subform based on certain criteria from another form. That is I have a form that I wish to determine the height of a subform from. I've added code to the form along the lines of:

Forms! {parent form name} . {subform name} . height = 6000

But this generates an error. I've also tried adding ".form" and ".detail" before the word height, but this didn't work either. If I try to assign the height value using the code that I have posted here, but call it from the parent form, it works fine. The only problem is that I can't evaluate the criteria from the parent form. Does anyone know a way that I could change the subform height from a form that isn't the parent form?

Thanks,

Matt
 
Does anyone know a way that I could change the subform height from a form that isn't the parent form?
This is an interesting question MS Jones. There are a couple of different possibilities here. First of all, I think you have two options: The inside height of a form object, and the actual height of a form "section". It wouldn't make much sense to use an inside height of another form for the height of your subform (It just doesn't seem congruent enough), so I'm assuming you're wanting to use a section height. Try this:
Code:
me.[SubformName].height = forms!OtherFormName.[SectionName].height
Also, be aware that any code that references a form can only run if that form is loaded (it doesn't necessarily need to have the focus).
 
{parent form name} . {subform name} .

Are you using one of those arcane foreign versions of Access that use different delimiters? In most versions, you would use parentheses instead of curly braces in the code above.
 
There seems to have been some confusion regarding my question. I have a form that has buttons on it. One particular button, when pressed, opens the next form (which has a subform on it), and closes the current form. However, before closing the current form, it changes the visibility of several of the objects on the newly opened form. All of these visibility changes work fine, I have code such as:

Forms!frmNewForm.Object1.Visible = False
etc

What I would also like to do here is change the size of the subform on the new form, from the default to a much larger size, since several of the objects below the subform are invisible in this view, and thus the form looks very empty with a (default) small-sized subform. As is my understanding, ajetrumpet interpretted my question as asking for a way to change the size of a subform to match the size of a different subform. And in answer to missingling: no my version of Access requires me to use standard brackets, I only used curly brackets to highlight that I was using psuedo code (I didn't want people posting comments about how "parent form name" isn't an appropriate name for a form). So sorry if that was confusing, the code that I have tried does use standard brackets.

The code that I have tried also works from the header form, and resizes the subform. But I can't get the criteria in the new form that I can get from the previous form. Basically, I currently have no way of knowing from the new form that the user has navigated here from the aforementioned form with the button, except that certain objects are no longer visible; and 'If statements' don't seem to be able to tell whether or not objects are visible. I've tried code like:

If Me.Object1.Visible = True Then
Me.frmSubForm.Height = 6000
ElseIf Me.Object1.Visible = False Then
Me.frmSubForm.Height = 2000
End If

But the first criterion always seems to be met, regardless of whether or not the object is visible. So I thought that it would be better (and more consistant) to set the size from the form with the button, where the visiblility of the objects is also set. However, if this is not possible then I could always just add a tickbox that defaults to 0, and then set it to -1 when I set the visibilities, then run an 'If statement' based on that. If anyone knows of a way to set the value from the form with the button then please let me know, since I'd rather tackle my problem without creating extra objects.

Thanks,

Matt
 
Matt, create a Public Function in the Master form that will accept a parameter of the size you want to make the subform that is on the Master form. Then, in your form that you use to open this Master/subform combo, you can issue this command:
Code:
Dim ReturnValue as Variant
ReturnValue = Forms!frmMaster.MyPublicFunctionName(ParameterForSubFormSize)
Again, this would be done after you have opened this "frmMaster" and before you close the current form.
 

Users who are viewing this thread

Back
Top Bottom