Get A Count Of Pages With Values Entered?

J

jamie

I am creating a form that has a Tab Control with multiple pages on it.
All of the pages contain different ways that users can select the
records they need. What I realized is that I need a way of getting a
count of all the pages that have selection criteria entered on them.

In a simplified way of explanation here is what I mean:

My form has a page where users can enter a state that a person lives in
and a page where they can select the person's age.

I essentially need to know if they had entered 'state' criteria, 'age'
criteria or both to get the records they need.

The trouble is that both of these pages (and I will be using over 20
such pages) have multiple ways of selecting - individual states,
individual ages, age ranges, etc etc .

So, what I would like is some code that will look at all the fields on
the page and if any fields are filled out return a value 1 else 0. And
give me a total of all the '1''s.

(Sorry if this is long winded and thanks for any help!)

Jamie
 
G

Guest

This would require 2 loops; 1 to loop through the pages in your tab control
and another to loop through all of the controls on each page. Below is a
very modified version of a post origanally made by Allen Browne. the
original post can be accessed at:

http://groups.google.ca/group/micro...read/thread/c472b9f9ebb2400d/12b35fd4c83b93a9


this assumes you pages are sequentially named pge1, pge2, pge3,...

Dim iPageKt As Long 'Number of pages in the tab control.
Dim i As Integer
Dim myCntrl As Control

iPageKt = Me.TabControlName.Pages.Count

'Loop through the pages of the tab control.
For i = 0 To iPageKt - 1
With Me("pge" & i)

'Loop through Control
Set myCntrl = Me.TabControlName.Pages

For Each myCntrl In Me.Controls
If Isnull(myCntrl)=False Then
'Do something the control a criteria
End if
Next myCntrl

End With
Next
End If

This has not been tested (just air code) but should get you on the right path.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top