473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to set a form that is a subform

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
3 1877
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
2
by: Claude | last post by:
Let' say we have an application for a production facility running 24/7 broken into 3 shifts 6-2,2-10,10-6 each production report date contains 3 shifts as above in each shift there can be from...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
12
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can...
9
by: PC Datasheet | last post by:
I'm stuck on something that seems should be easy and I need some help. My main form has an option group with five options. My subform chooses from different lists depending on which option is...
14
by: Anja | last post by:
Hi everyone, I have a sub form that references a query to get the results. However, what I want to do is filter the results further based on a certain criteria. How can I tell the sub form to...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
6
NeoPa
by: NeoPa | last post by:
Introduction The first thing to understand about Sub-Forms is that, to add a form onto another form takes a special Subform control. This Subform control acts as a container for the form that you...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.