473,398 Members | 2,427 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,398 software developers and data experts.

Loop through controls on main form with several sub forms

22
Hi not sure if my earlier post was sent due to idle time so here I go again....

On my main form when I press the save button it has to loop through several sub forms within tabs and determine if the optiongroup within them are set to a certain value.

How would I do a single loop structure to accomplish this from my main form calle frmMain. Presently I am doing it separately for each form as below:
Expand|Select|Wrap|Line Numbers
  1.    For Each ctl In Form_frmHeader.Controls
  2.         Select Case ctl.ControlType
  3.         Case acOptionGroup
  4.             If ctl.Value = 2 Then
  5.                 Correct = True
  6.                 Exit For
  7.             End If
  8.         End Select
  9.     Next ctl
  10.  
  11.    For Each ctl In Form_frmLines.Controls
  12.         Select Case ctl.ControlType
  13.         Case acOptionGroup
  14.             If ctl.Value = 2 Then
  15.                 Correct = True
  16.                 Exit For
  17.             End If
  18.         End Select
  19.     Next ctl
  20.  
  21.    For Each ctl In Form_frmSummary.Controls
  22.         Select Case ctl.ControlType
  23.         Case acOptionGroup
  24.             If ctl.Value = 2 Then
  25.                 Correct = True
  26.                 Exit For
  27.             End If
  28.         End Select
  29.     Next ctl
  30.    For Each ctl In Form_frmDocHist.Controls
  31.         Select Case ctl.ControlType
  32.         Case acOptionGroup
  33.             If ctl.Value = 2 Then
  34.                 Correct = True
  35.                 Exit For
  36.             End If
  37.         End Select
  38.     Next ctl
  39.    For Each ctl In Form_frmNotes.Controls
  40.         Select Case ctl.ControlType
  41.         Case acOptionGroup
  42.             If ctl.Value = 2 Then
  43.                 Correct = True
  44.                 Exit For
  45.             End If
  46.         End Select
  47.     Next ctl
  48.  
thanks
Jul 22 '10 #1
2 1266
Guido Geurs
767 Expert 512MB
Normally You can run through the active forms with this=
(see attachment)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim ACTIVE As Integer
  3. Dim i As Integer
  4.    For i = 0 To Forms.Count - 1
  5.       If Forms(i).Check1 Then ACTIVE = ACTIVE + 1  
  6.    Next
  7.    Text1.Text = ACTIVE
  8. End Sub
Jul 23 '10 #2
p4willi
22
As always - thanks ggeu. Your tip has helped me.
Jul 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: pepino13 | last post by:
Hello, I have a a form called frmMissyFact, I have copied this form and called it frmMissyFactBackup which reads data from a backup database of the week before. I brought frmMissyFactBackup into...
4
by: Craig M | last post by:
Hi, I have 2 forms, frmretailorders, and frmretailorderline. in the oncurrent of the main form, I check what the value of !status is. If it is "complete", then i disable all text and combo...
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...
3
by: jquest | last post by:
I have a database about services and installations as well as warranty and services for a company I run. The main form is the customer info form. On this I record names, address and phone numbers....
5
by: Randy | last post by:
The following code, which runs when I click File->Save in my main form, finds my save button in my mdi child for just fine. The question is: how do I invoke the Save method in the child form? ...
1
by: dBNovice | last post by:
Please help! I have 3 forms: Task, Subtask, Elements. Elements is a subform of Subtask and Subtask is a subform of Task. I am able to navigate from Task to Subform to Element and from Element to...
1
by: Vladimir O¾ura | last post by:
I am building a Pocket PC application in C#. I have 5 forms (1 main and 4 sub forms). The main form must always load first. The sub forms are loaded from the main form. The application is run...
0
by: Kristian Frost | last post by:
Hi, I'm just getting started with VB.Net, and I'm having trouble getting the routing around of some of the data straight in my mind, which has led me to the following problem. Basically, I'm...
4
by: =?Utf-8?B?WVhR?= | last post by:
Me.Controls can get all the controls on the form, but i want to get all the controls include non-from controls, for example ToolTip, ContextMenuStrip... Thank you
11
by: OldBirdman | last post by:
I have a form with several bound textboxes. These are routinely updated by User. The table in RecordSource for this form currently has 8 fields not shown on this form, but which occasionally need...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.