Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Frame as variable (newbie question)

Hello all,

I'm using Excel 2000. I have a form with 7 frames, each with 10 comboboxes.
I can loop through all the boxes on each frame if I hardcode it.

for each control in userform1.frame1.controls...

I'd like to be able to change frame1 to a variable so I only have to use one
sub as opposed to 7.

dim x as ???
?set x = combobox1.parent?
for each control in userform1.x.controls...

Basically, I've written a sub that, on the combobox change event, will alert
the user if the same value is in more than one combobox in the same frame. I
don't want to prevent duplication, just let the user know with a msgbox. The
sub is written & works fine, I just can't make it work for more than one
frame. My plan is to declare a public variable, and set it's value in the
change event proc.

If my idea isn't possible, how can I find out what frame the combobox that
changed is in?

Thanks in advance,
Rik
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Frame as variable (newbie question)

Hi Rik,

I have a simple idea. Why don't you name for each
controls depending on the name of the frame?
For example, assume you have 2 frames named Frm1 and Frm2
on the userform.
On Frm1, place 2 TextBox controls as Frm1_TextBox1 and
Frm1_TextBox2.
On Frm2, place 2 TextBox controls as Frm2_TextBox1 and
Frm2_TextBox2.

So, you can use one sub as opposed above 2 Frames using
an argument.
Please have a look at the following procedure.

Private Sub CommandButton1_Click()
InputValue 1
End Sub

Private Sub CommandButton2_Click()
InputValue 2
End Sub

Private Sub InputValue(ByVal FrmIndex As Long)
Dim strFrmPrf As String
strFrmPrf = "Frm" & FrmIndex & "_"
Me.Controls(strFrmPrf & "TextBox1").Text = "Hey"
Me.Controls(strFrmPrf & "TextBox2").Text = "What's Up"
End Sub

HTH
Colo

-----Original Message-----
Hello all,

I'm using Excel 2000. I have a form with 7 frames, each

with 10 comboboxes.
I can loop through all the boxes on each frame if I

hardcode it.

for each control in userform1.frame1.controls...

I'd like to be able to change frame1 to a variable so I

only have to use one
sub as opposed to 7.

dim x as ???
?set x = combobox1.parent?
for each control in userform1.x.controls...

Basically, I've written a sub that, on the combobox

change event, will alert
the user if the same value is in more than one combobox

in the same frame. I
don't want to prevent duplication, just let the user

know with a msgbox. The
sub is written & works fine, I just can't make it work

for more than one
frame. My plan is to declare a public variable, and set

it's value in the
change event proc.

If my idea isn't possible, how can I find out what frame

the combobox that
changed is in?

Thanks in advance,
Rik
.

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
Variable Frame Reference Branden Durst New Users to Excel 1 February 17th 10 09:16 PM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
How to attach legend frame to chart frame? holg3r Charts and Charting in Excel 2 July 7th 05 11:41 PM
VBA Question - How to print a frame within a template Dave Peterson[_3_] Excel Programming 0 July 8th 04 10:53 PM
VBA Question - How to print a frame within a template gitcypher[_27_] Excel Programming 0 July 8th 04 08:47 PM


All times are GMT +1. The time now is 11:25 PM.

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"