Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Looping through controls on a MultiPage control

Hi All

I would like to clear textboxes on a MultiPage control. The user
chooses to clear textboxes on CURRENT page or ALL pages. My code is
below.

The problem is that Current works, but All doesn't. frmStart (the
whole form) does not pass, and I get a data mismatch error. If I
change the data type in ClearInputs from MSForms.Control to Variant,
it will work, but this seems sloppy to me - I'd like to know the
actual data type to use. I also tried using Control as the data type,
but got same error. Any suggestions?

Thanks in advance

Paul Martin
Melbourne, Australia


________________________________________
Private Sub cmdAll_Click()
' THIS FAILS - frmStart does not pass to ClearInputs
ClearInputs frmStart ' clear all textboxes on form
End Sub
________________________________________
Private Sub cmdCurrent_Click()
' THIS WORKS
Dim i as Integer

With frmStart.mpgInputs
i = .Value ' get current page of MultiPage
ClearInputs .Pages(i) ' clear textboxes on current page
End With
End Sub
________________________________________
Private Sub ClearInputs(ByRef ctlParentA As MSForms.Control)
Dim ctl As MSForms.Control

For Each ctl In ctlParentA.Controls
If TypeOf ctl Is MSForms.TextBox Then
ctl.Value = ""
End If
Next ctl
End Sub
________________________________________
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Looping through controls on a MultiPage control

Private Sub cmdAll_Click()
Dim p As MSForms.Control
For Each p In frmStart.mpgInputs.Pages
ClearInputs p
Next
End Sub


Regards - Steve.

"Paul Martin" wrote in message om...
Hi All

I would like to clear textboxes on a MultiPage control. The user
chooses to clear textboxes on CURRENT page or ALL pages. My code is
below.

The problem is that Current works, but All doesn't. frmStart (the
whole form) does not pass, and I get a data mismatch error. If I
change the data type in ClearInputs from MSForms.Control to Variant,
it will work, but this seems sloppy to me - I'd like to know the
actual data type to use. I also tried using Control as the data type,
but got same error. Any suggestions?

Thanks in advance

Paul Martin
Melbourne, Australia


________________________________________
Private Sub cmdAll_Click()
' THIS FAILS - frmStart does not pass to ClearInputs
ClearInputs frmStart ' clear all textboxes on form
End Sub
________________________________________
Private Sub cmdCurrent_Click()
' THIS WORKS
Dim i as Integer

With frmStart.mpgInputs
i = .Value ' get current page of MultiPage
ClearInputs .Pages(i) ' clear textboxes on current page
End With
End Sub
________________________________________
Private Sub ClearInputs(ByRef ctlParentA As MSForms.Control)
Dim ctl As MSForms.Control

For Each ctl In ctlParentA.Controls
If TypeOf ctl Is MSForms.TextBox Then
ctl.Value = ""
End If
Next ctl
End Sub
________________________________________



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Looping through controls on a MultiPage control

Responded to your email, but the reply was rejected.

specifying msforms as a qualifier eliminates confusion with controls in
other libraries with the same type name.

--
regards,
Tom Ogilvy

"Paul Martin" wrote in message
om...
Hi All

I would like to clear textboxes on a MultiPage control. The user
chooses to clear textboxes on CURRENT page or ALL pages. My code is
below.

The problem is that Current works, but All doesn't. frmStart (the
whole form) does not pass, and I get a data mismatch error. If I
change the data type in ClearInputs from MSForms.Control to Variant,
it will work, but this seems sloppy to me - I'd like to know the
actual data type to use. I also tried using Control as the data type,
but got same error. Any suggestions?

Thanks in advance

Paul Martin
Melbourne, Australia


________________________________________
Private Sub cmdAll_Click()
' THIS FAILS - frmStart does not pass to ClearInputs
ClearInputs frmStart ' clear all textboxes on form
End Sub
________________________________________
Private Sub cmdCurrent_Click()
' THIS WORKS
Dim i as Integer

With frmStart.mpgInputs
i = .Value ' get current page of MultiPage
ClearInputs .Pages(i) ' clear textboxes on current page
End With
End Sub
________________________________________
Private Sub ClearInputs(ByRef ctlParentA As MSForms.Control)
Dim ctl As MSForms.Control

For Each ctl In ctlParentA.Controls
If TypeOf ctl Is MSForms.TextBox Then
ctl.Value = ""
End If
Next ctl
End Sub
________________________________________



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Looping through controls on a MultiPage control

Thanks Stevie

I knew it was simple, just couldn't find it. Your solution was great,
though I declared p as MSForms.Page.

Regards

Paul

Thanks also, Tom.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to loop through controls on a MultiPage 42N83W Excel Programming 11 February 14th 05 11:32 PM
Multipage Controls - Experts Only Dee Veloper[_2_] Excel Programming 1 January 25th 05 11:57 PM
Progmatically adding controls in multipage Ajit Excel Programming 0 January 4th 05 09:39 PM
Set Focus Problem for textbox control on multipage control ExcelDeveloperSPR Excel Programming 1 July 16th 04 08:54 PM
Events for Controls in a Multipage Control George[_18_] Excel Programming 4 February 18th 04 05:56 PM


All times are GMT +1. The time now is 09:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"