FRAMES IN A FORM

J

JJ

OS= XP Prof SP2, MS Office 2003 SP2.

I have a form with 5 different frames with option buttons. When you
select option1 in frame1, then frame1 will be hidden and frame2 will
become visible. When you select opion2 in frame1, then frame1 will be
hidden and frame3 will become visible. Everything is working fine
apart from the fact that the frames obviously display where I have
created them on the form and I cannot drag and drop them to their
correct display places as they are similars size and is then inserted
into another frame. Is there a way that I can programmatically tell
the frame on which line and what column to start up once you click
option1 in frame1 instead of changing the frame properties or dragging
same?

Any ideas or assistance will be greatly appreciated.
Thanx
 
S

Shauna Kelly

Hi JJ

I assume you're using a UserForm, not a frame and buttons within a document.

What I usually do in a case like this is to make the form very wide, and
position the frames side by side so I can see what I'm doing and work on
them easily. In the form's UserForm_Initialize event set the width of the
form as you want it to display using something like
Me.Width = 400

When a user clicks one of the option buttons, you could run code something
like this (although I hope you have better names for your controls than the
default ones):

With Me
If .OptionButton1 Then
'Hide 1 and 3; show 2
.Frame1.Visible = False
.Frame3.Visible = False

'show Frame 2 and position it where Frame 1 is
.Frame2.Visible = True
.Frame2.Top = .Frame1.Top
.Frame2.Left = .Frame2.Top

ElseIf .OptionButton2 Then
'Hide 1 and 2; show 3
.Frame1.Visible = False
.Frame2.Visible = False

'show Frame 3 and position it where Frame 1 is
.Frame3.Visible = True
.Frame3.Top = .Frame1.Top
.Frame3.Left = .Frame2.Top

End If
End With

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
J

JJ

Hi JJ

I assume you're using a UserForm, not a frame and buttons within a document.

What I usually do in a case like this is to make the form very wide, and
position the frames side by side so I can see what I'm doing and work on
them easily. In the form's UserForm_Initialize event set the width of the
form as you want it to display using something like
Me.Width = 400

When a user clicks one of the option buttons, you could run code something
like this (although I hope you have better names for your controls than the
default ones):

With Me
If .OptionButton1 Then
'Hide 1 and 3; show 2
.Frame1.Visible = False
.Frame3.Visible = False

'show Frame 2 and position it where Frame 1 is
.Frame2.Visible = True
.Frame2.Top = .Frame1.Top
.Frame2.Left = .Frame2.Top

ElseIf .OptionButton2 Then
'Hide 1 and 2; show 3
.Frame1.Visible = False
.Frame2.Visible = False

'show Frame 3 and position it where Frame 1 is
.Frame3.Visible = True
.Frame3.Top = .Frame1.Top
.Frame3.Left = .Frame2.Top

End If
End With

Hope this helps.

Shauna Kelly. Microsoft MVP.http://www.shaunakelly.com/word








- Show quoted text -

Shauna, thanx it worked. I found a similar solution from an old post
in 2004 but yours is easier. Works like a CHARM!!!! Thank you sooo
much.
 
S

Shauna Kelly

Hi

I'm glad it worked. I assume you discovered the errors in what I sent.

..Frame2.Left = .Frame2.Top
should have been
..Frame2.Left = .Frame1.left

and similarly for the Frame3 positioning.

Shauna

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top