Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default CheckBoxes on MultiPage

Initially I was setting the values of a group of CheckBoxes on a UserForm
via the following code (and it worked well):

Private Sub Binary2CB()
cbResult = "0011001101" ' (for test purposes)
Dim x As Integer
For x = 1 To 10
If Mid(cbResult, x, 1) = 1 Then
Userform1.Controls("CheckBox" & x).Value = True
End If
Next x
End Sub

I've since moved the CheckBoxes onto a Mulitpage control
on the same UserForm.
How can I modify the code above to make this work?
(I've tried a number of different manipulations but can't seem to find the
right combination).

Thanks,
John


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default CheckBoxes on MultiPage

Have you tried

Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Wilson" wrote in message
...
Initially I was setting the values of a group of CheckBoxes on a UserForm
via the following code (and it worked well):

Private Sub Binary2CB()
cbResult = "0011001101" ' (for test purposes)
Dim x As Integer
For x = 1 To 10
If Mid(cbResult, x, 1) = 1 Then
Userform1.Controls("CheckBox" & x).Value = True
End If
Next x
End Sub

I've since moved the CheckBoxes onto a Mulitpage control
on the same UserForm.
How can I modify the code above to make this work?
(I've tried a number of different manipulations but can't seem to find the
right combination).

Thanks,
John




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default CheckBoxes on MultiPage

Bob,

No, I hadn't tried that.
Your suggestion didn't work until I removed the UserForm1 reference but
you did get me started in the right direction.

The following:
MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
Did work though.

There were actually 25 CheckBoxes across the 3 pages on that MultiPage
so my final code ended up looking like this:

Private Sub Binary2CB()
cbResult = "0100000000001110000000010" ' (For test purposes)
Dim x As Integer
For x = 1 To 25
If Mid(cbResult, x, 1) = 1 Then
If x < 12 Then
MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
Else
If x 21 Then
MultiPage1.Pages(2).Controls("CheckBox" & x).Value =
True
Else
MultiPage1.Pages(1).Controls("CheckBox" & x).Value =
True
End If
End If
End If
Next x
End Sub

Thank you very much for your help,
John



"Bob Phillips" wrote in message
...
Have you tried

Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Wilson" wrote in message
...
Initially I was setting the values of a group of CheckBoxes on a UserForm
via the following code (and it worked well):

Private Sub Binary2CB()
cbResult = "0011001101" ' (for test purposes)
Dim x As Integer
For x = 1 To 10
If Mid(cbResult, x, 1) = 1 Then
Userform1.Controls("CheckBox" & x).Value = True
End If
Next x
End Sub

I've since moved the CheckBoxes onto a Mulitpage control
on the same UserForm.
How can I modify the code above to make this work?
(I've tried a number of different manipulations but can't seem to find
the
right combination).

Thanks,
John






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default CheckBoxes on MultiPage

John

Did you change the name of your userform? I didn't need to preface the
control reference with the mulitpage, so it sounds like you may have two
userforms. You didn't say what error you were getting, if any, so it's hard
to say if that's it. If the code is in the userform's code module, you
should be able to use

Me.Controls("CheckBox" & x).Value

Me is a keyword that refers to the class it's contained in, in this case the
userform. If you ever happen to change the name of the userform, Me will
still work.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

John Wilson wrote:
Bob,

No, I hadn't tried that.
Your suggestion didn't work until I removed the UserForm1 reference
but you did get me started in the right direction.

The following:
MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
Did work though.

There were actually 25 CheckBoxes across the 3 pages on that MultiPage
so my final code ended up looking like this:

Private Sub Binary2CB()
cbResult = "0100000000001110000000010" ' (For test purposes)
Dim x As Integer
For x = 1 To 25
If Mid(cbResult, x, 1) = 1 Then
If x < 12 Then
MultiPage1.Pages(0).Controls("CheckBox" & x).Value =
True Else
If x 21 Then
MultiPage1.Pages(2).Controls("CheckBox" & x).Value
= True
Else
MultiPage1.Pages(1).Controls("CheckBox" & x).Value
= True
End If
End If
End If
Next x
End Sub

Thank you very much for your help,
John



"Bob Phillips" wrote in message
...
Have you tried

Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Wilson" wrote in message
...
Initially I was setting the values of a group of CheckBoxes on a
UserForm via the following code (and it worked well):

Private Sub Binary2CB()
cbResult = "0011001101" ' (for test purposes)
Dim x As Integer
For x = 1 To 10
If Mid(cbResult, x, 1) = 1 Then
Userform1.Controls("CheckBox" & x).Value = True
End If
Next x
End Sub

I've since moved the CheckBoxes onto a Mulitpage control
on the same UserForm.
How can I modify the code above to make this work?
(I've tried a number of different manipulations but can't seem to
find the
right combination).

Thanks,
John



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default CheckBoxes on MultiPage

Dick,

Yes, I did change the name of the UserForm to "OCMC".
Bob gave me this:
Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
which I changed to this:
OCMC.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
and it didn't work.
The error that the above gives is "Object doesn't support this property or
method"

The following did work though:
MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
I tried this and it also worked:
Me.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True

All the code is in the UserForm module.
Looking at it again, it really doesn't make sense why if "Me" works
and no preface works, why wouldn't "OCMC" (the actual name of
the UserForm) wouldn't work.

Again, Bob did steer me in the right direction ("Pages(0)" was the
critical part that I was missing) and I did get it to work.

Thanks,
John


"Dick Kusleika" wrote in message
...
John

Did you change the name of your userform? I didn't need to preface the
control reference with the mulitpage, so it sounds like you may have two
userforms. You didn't say what error you were getting, if any, so it's
hard to say if that's it. If the code is in the userform's code module,
you should be able to use

Me.Controls("CheckBox" & x).Value

Me is a keyword that refers to the class it's contained in, in this case
the userform. If you ever happen to change the name of the userform, Me
will still work.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

John Wilson wrote:
Bob,

No, I hadn't tried that.
Your suggestion didn't work until I removed the UserForm1 reference
but you did get me started in the right direction.

The following:
MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True
Did work though.

There were actually 25 CheckBoxes across the 3 pages on that MultiPage
so my final code ended up looking like this:

Private Sub Binary2CB()
cbResult = "0100000000001110000000010" ' (For test purposes)
Dim x As Integer
For x = 1 To 25
If Mid(cbResult, x, 1) = 1 Then
If x < 12 Then
MultiPage1.Pages(0).Controls("CheckBox" & x).Value =
True Else
If x 21 Then
MultiPage1.Pages(2).Controls("CheckBox" & x).Value
= True
Else
MultiPage1.Pages(1).Controls("CheckBox" & x).Value
= True
End If
End If
End If
Next x
End Sub

Thank you very much for your help,
John



"Bob Phillips" wrote in message
...
Have you tried

Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Wilson" wrote in message
...
Initially I was setting the values of a group of CheckBoxes on a
UserForm via the following code (and it worked well):

Private Sub Binary2CB()
cbResult = "0011001101" ' (for test purposes)
Dim x As Integer
For x = 1 To 10
If Mid(cbResult, x, 1) = 1 Then
Userform1.Controls("CheckBox" & x).Value = True
End If
Next x
End Sub

I've since moved the CheckBoxes onto a Mulitpage control
on the same UserForm.
How can I modify the code above to make this work?
(I've tried a number of different manipulations but can't seem to
find the
right combination).

Thanks,
John





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
MultiPage tab? capt Excel Discussion (Misc queries) 2 January 28th 08 08:01 PM
MultiPage OM Excel Discussion (Misc queries) 2 April 7th 06 01:31 PM
How do I use multipage Lawrence M Watt Excel Discussion (Misc queries) 1 October 24th 05 02:55 PM
vba - using multipage ajliaks[_23_] Excel Programming 3 August 9th 04 01:29 PM
MultiPage Michael[_25_] Excel Programming 3 January 6th 04 12:49 PM


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