Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default For Each...Loop using Pages in a Multipage Control

I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default For Each...Loop using Pages in a Multipage Control

try

dim page as control

:)
susan


On Jul 1, 2:52*pm, RyanH wrote:
I am scattered today. *Yesterday this code was working fine and today it is
not. *I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

* * 'disables all three pages
* * * * For Each pg In mpgIllumination.Pages
* * * * * * pg.Enabled = False
* * * * Next pg

End Sub

--
Cheers,
Ryan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default For Each...Loop using Pages in a Multipage Control

of course i meant

dim pg as control

susan


On Jul 1, 2:52*pm, RyanH wrote:
I am scattered today. *Yesterday this code was working fine and today it is
not. *I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

* * 'disables all three pages
* * * * For Each pg In mpgIllumination.Pages
* * * * * * pg.Enabled = False
* * * * Next pg

End Sub

--
Cheers,
Ryan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default For Each...Loop using Pages in a Multipage Control

That seems to work! Why would my code not work? Defining pg as a Page
should work I would think.
--
Cheers,
Ryan


"Susan" wrote:

try

dim page as control

:)
susan


On Jul 1, 2:52 pm, RyanH wrote:
I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default For Each...Loop using Pages in a Multipage Control

Ooops! No can do. I just realized that Dim pg as Control disables all the
controls in the page. I guess I will have to do this below. I figured I'd
just use the For Each Loop

'disables all three pages
For i = 0 To 2
mpgIllumination.Pages(i).Enabled = False
Next i
--
Cheers,
Ryan


"Susan" wrote:

try

dim page as control

:)
susan


On Jul 1, 2:52 pm, RyanH wrote:
I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default For Each...Loop using Pages in a Multipage Control

i don't think there is a type as "page". anything on a userform is
dimmed as a control. then you can specify what type of control you're
looking for.

like this:

dim oControl as Control

if typeof oControl is MSForms.multipage then..........
if typeof oControl is MSForms.textbox then.........

:)
susan


On Jul 1, 3:16*pm, RyanH wrote:
That seems to work! *Why would my code not work? *Defining pg as a Page
should work I would think.
--
Cheers,
Ryan



"Susan" wrote:
try


dim page as control


:)
susan


On Jul 1, 2:52 pm, RyanH wrote:
I am scattered today. *Yesterday this code was working fine and today it is
not. *I am getting a Type MisMatch Error indicated below, why?


Private Sub cboIllumination_Change()


Dim pg As Page


* * 'disables all three pages
* * * * For Each pg In mpgIllumination.Pages
* * * * * * pg.Enabled = False
* * * * Next pg


End Sub


--
Cheers,
Ryan- Hide quoted text -


- Show quoted text -


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default For Each...Loop using Pages in a Multipage Control

yes, then you'd have to specify what pg is, i.e., what type of
control. well, wait a minute, what difference does it make if it
disables all the controls on the page if the page itself is disabled?
if the whole page is disabled you won't be able to use anything on the
page anyway.

i guess your way is better for you if it does what you want it to!
:)
susan


On Jul 1, 3:28*pm, RyanH wrote:
Ooops! *No can do. *I just realized that Dim pg as Control disables all the
controls in the page. *I guess I will have to do this below. *I figured I'd
just use the For Each Loop

* * 'disables all three pages
* * * * For i = 0 To 2
* * * * * * mpgIllumination.Pages(i).Enabled = False
* * * * Next i
--
Cheers,
Ryan



"Susan" wrote:
try


dim page as control


:)
susan


On Jul 1, 2:52 pm, RyanH wrote:
I am scattered today. *Yesterday this code was working fine and today it is
not. *I am getting a Type MisMatch Error indicated below, why?


Private Sub cboIllumination_Change()


Dim pg As Page


* * 'disables all three pages
* * * * For Each pg In mpgIllumination.Pages
* * * * * * pg.Enabled = False
* * * * Next pg


End Sub


--
Cheers,
Ryan- Hide quoted text -


- Show quoted text -


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default For Each...Loop using Pages in a Multipage Control

Your code worked ok for me.

What line caused the error?

(I don't have a guess, but maybe someone else will.)

RyanH wrote:

I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default For Each...Loop using Pages in a Multipage Control

For some reason this code was working yesterday. You even helped me with a
portion of it. But today it changed its mind and decided not to work so I
switched to this:

'disables all three pages
For i = 0 To 2
mpgIllumination.Pages(i).Enabled = False
Next i

Thanks for the help
--
Cheers,
Ryan


"Dave Peterson" wrote:

Your code worked ok for me.

What line caused the error?

(I don't have a guess, but maybe someone else will.)

RyanH wrote:

I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default For Each...Loop using Pages in a Multipage Control

I think you have a problem somewhere that you're masking. Your other code is ok
as far as I can see.

And if you add pages to that multipage control, you may not want to go back to
change the "from 0 to 2" lines. Easily fixed, yes. But it's easily missed,
too.

I'd use something like this to disable all the pages--no matter the count.

Dim i As Long
'disables all pages
With Me.mpgIllumination
For i = 0 To .Count - 1
.Pages(i).Enabled = False
Next i
End With

Much closer to what your "for each" code tried to do.

RyanH wrote:

For some reason this code was working yesterday. You even helped me with a
portion of it. But today it changed its mind and decided not to work so I
switched to this:

'disables all three pages
For i = 0 To 2
mpgIllumination.Pages(i).Enabled = False
Next i

Thanks for the help
--
Cheers,
Ryan

"Dave Peterson" wrote:

Your code worked ok for me.

What line caused the error?

(I don't have a guess, but maybe someone else will.)

RyanH wrote:

I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan


--

Dave Peterson


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default For Each...Loop using Pages in a Multipage Control

Absolutely Dave! Thanks for the tip!
--
Cheers,
Ryan


"Dave Peterson" wrote:

I think you have a problem somewhere that you're masking. Your other code is ok
as far as I can see.

And if you add pages to that multipage control, you may not want to go back to
change the "from 0 to 2" lines. Easily fixed, yes. But it's easily missed,
too.

I'd use something like this to disable all the pages--no matter the count.

Dim i As Long
'disables all pages
With Me.mpgIllumination
For i = 0 To .Count - 1
.Pages(i).Enabled = False
Next i
End With

Much closer to what your "for each" code tried to do.

RyanH wrote:

For some reason this code was working yesterday. You even helped me with a
portion of it. But today it changed its mind and decided not to work so I
switched to this:

'disables all three pages
For i = 0 To 2
mpgIllumination.Pages(i).Enabled = False
Next i

Thanks for the help
--
Cheers,
Ryan

"Dave Peterson" wrote:

Your code worked ok for me.

What line caused the error?

(I don't have a guess, but maybe someone else will.)

RyanH wrote:

I am scattered today. Yesterday this code was working fine and today it is
not. I am getting a Type MisMatch Error indicated below, why?

Private Sub cboIllumination_Change()

Dim pg As Page

'disables all three pages
For Each pg In mpgIllumination.Pages
pg.Enabled = False
Next pg

End Sub

--
Cheers,
Ryan

--

Dave Peterson


--

Dave Peterson

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
Enable Property of Multipage Control Pages = CheckBox.Value RyanH Excel Programming 2 May 13th 08 02:10 PM
Loop through pages in multipage control ExcelMonkey Excel Programming 2 May 2nd 07 09:47 PM
how to switch pages in a multipage control by a commandbutton furbiuzzu Excel Programming 2 September 11th 06 03:16 PM
Multipage Control Pages - Changing Index Value in Code misseill Excel Programming 1 July 13th 05 04:55 PM
Multipage Control Pages - Changing Index Value in Code misseill Excel Programming 0 July 13th 05 04:32 PM


All times are GMT +1. The time now is 08:35 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"