By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

how to set a form that is a subform

P: n/a
I have a function that increases the size of each control on a form. I
would like to do the same on a sub form, but this does not seem to work. My
syntax thus far is

set frm = screen.activeform
for each ctl in frm.controls
ctl.width = ctl.width + 1
....
if ctl.controltype = acsubform then
set Subfrm = frm.controls(ctl.name).form
for each subCtl in subfrm
...
next subCtl
next ctl

everything works fine, but I do not seem to be able to set the subform as a
form object.

Does anyone have any idea on how to make this function work???

TIA
- Nicolaas
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If you are trying to resize the controls in a form and any subforms that it
contains, the example below shows how to do that.

It actually resizes everything to 1 inch--not very useful, but it
demonstrates the technique of calling the subforms recursively.

Function ResizeFormControls(frm As Form, Optional ParentFormName As String)
Dim ctl As Control
Dim strThisForm As String

If Len(ParentFormName) = 0 Then
strThisForm = frm.Name
Else
strThisForm = ParentFormName & "." & frm.Name & ".Form"
End If

For Each ctl In frm.Controls
Debug.Print strThisForm & "." & ctl.Name
If ctl.ControlType = acSubform Then
Call ResizeFormControls(ctl.Form, strThisForm)
Else
ctl.Width = 1440
End If
Next
End Function
Definition of recursive: See recursive.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"WindAndWaves" <ac****@ngaru.com> wrote in message
news:Jh*******************@news.xtra.co.nz...
I have a function that increases the size of each control on a form. I
would like to do the same on a sub form, but this does not seem to work. My syntax thus far is

set frm = screen.activeform
for each ctl in frm.controls
ctl.width = ctl.width + 1
....
if ctl.controltype = acsubform then
set Subfrm = frm.controls(ctl.name).form
for each subCtl in subfrm
...
next subCtl
next ctl

everything works fine, but I do not seem to be able to set the subform as a form object.

Does anyone have any idea on how to make this function work???

TIA
- Nicolaas

Nov 13 '05 #2

P: n/a
that is cool Allen. I never even knew that you could call a function in
itself. It seems very circular to me, but nevermind, if it works then that
is brilliant!

Thank you so much. This is really exciting stuff. Great
Nov 13 '05 #3

P: n/a
Yes, you do have to be careful that the recursive call is not circular.

In this case it won't be, because the nesting of subforms is not infinite
nor circular. So the code calls another instance of the function to handle
each subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"WindAndWaves" <ac****@ngaru.com> wrote in message
news:l3*******************@news.xtra.co.nz...
that is cool Allen. I never even knew that you could call a function in
itself. It seems very circular to me, but nevermind, if it works then that is brilliant!

Thank you so much. This is really exciting stuff. Great

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.