Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Help with For Each ... Next and control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ayo - 16 Sep 2007 19:36 GMT
I have a form that contains a Multipage control, with 4 pages, and about 5
textboxes, 5 labels and 5 commandbuttons on each page. I am trying to use
"For Each ctl In frmOpenFiles.Controls
       If TypeName(ctl) = "TextBox" Then" to go through the controls on the
form and only look for the textboxes.

My problem is that I am looking for a way to do the textboxes for before
the other controls or if there is a way to tell the programme which controls
to start with.
I want it to start with the textboxes on the first page of the Multipage,
then the textboxes on the second page and so on.
Leith Ross - 16 Sep 2007 21:23 GMT
>  I have a form that contains a Multipage control, with 4 pages, and about 5
> textboxes, 5 labels and 5 commandbuttons on each page. I am trying to use
[quoted text clipped - 7 lines]
>  I want it to start with the textboxes on the first page of the Multipage,
> then the textboxes on the second page and so on.

Hello Ayo,

This macro steps through each page of the MultiPage control and counts
the number of TextBoxes on each page, if any. After each page is
examined, a MessageBox displays the count. The macro was placed in the
UserForm Click event. You can use this code as template for your own.

Private Sub UserForm_Click()

 Dim Ctrls As Object
 Dim I As Long, N As Long
 Dim txtbox As Object

   For I = 0 To UserForm1.MultiPage1.Pages.Count - 1
     Set Ctrls = UserForm1.MultiPage1.Pages(I).Controls
       For Each txtbox In Ctrls
         N = N + 1
       Next txtbox
     MsgBox "Page(" & I & ") has " & N & " TextBoxes"
     N = 0
   Next I

End Sub

Sincerely,
Leith Ross
Ayo - 16 Sep 2007 21:38 GMT
Thanks a lot Leith. I think this might actually do the trick.

> >  I have a form that contains a Multipage control, with 4 pages, and about 5
> > textboxes, 5 labels and 5 commandbuttons on each page. I am trying to use
[quoted text clipped - 34 lines]
> Sincerely,
> Leith Ross
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.