2 frames in a form

i have 2 frames in my form. i need to perform this. an event in frame1 makes it invisible and i want to display frame2 in the same location as that of frame1. but this isnt happening. during design, the frame2 is on frame1 and so frame2 becomes an obj of frame1. i tried "send to back" option on frame2, but dosent work.
kindly help
thanks
Sankar030999Asked:
Who is Participating?
 
wsh2Connect With a Mentor Commented:
Right click on the Frame that is contained INSIDE of the other Frame and select Cut. Then place and click your mouse pointer on the form OUTSIDE of the Frame that is left.. right click again and Paste. As long as the one Frame is contained in the other.. the Outer frame is considered the Parent.. and the Inner form will be subject to any dictates of it.

As to sizing the second Frame, the most efficient way to do it is to use the Move method. Eg.

With Frame1
  Frame2.Move .Left, .Top, .Width, .Height
End With



0
 
ofirgCommented:
1) open new form
2) add frame1
3) click on the form background
4) add a scond control

now you have two frame on the form and not one within enother.
0
 
GivenRandyCommented:
Were you using something like this:

Private Sub Command1_Click()
    Frame2.Left = Frame1.Left
    Frame2.Top = Frame1.Top
    Frame2.Width = Frame1.Width
    Frame2.Height = Frame1.Height
    Frame2.Visible = True
    Frame1.Visible = False
End Sub

Private Sub Command2_Click()
    Frame1.Left = Frame2.Left
    Frame1.Top = Frame2.Top
    Frame1.Width = Frame2.Width
    Frame1.Height = Frame2.Height
    Frame1.Visible = True
    Frame2.Visible = False
End Sub

Where Command1 hides Frame1 and shows Frame2 where Frame1 was.  Command2 does the reverse.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fibdevCommented:
Try it like this:

Sub Form_Load()
  Frame1.visible = true
  Frame2.visible = false
end sub


Sub EventTrigger_Click() ' eventtrigger being the event you mentioned

  Frame1.visible = false

 ' Do your stuff here
  With Frame2
     .top = Frame1.top
     .left = Frame1.left
     .hieght = Frame1.hieght
     .width = Frame1.Width
  End With
  Frame2.visible = true

End Sub
0
 
fibdevCommented:
with my example

create frame1 on the form first
then create frame2 anywhere on the form (out of the way would be best because it will be sized and posistioned at run time).
0
 
fibdevCommented:
this may be a little faster:

Sub EventTrigger_Click() ' eventtrigger being the event you mentioned

  ' Do your stuff here
  With Frame2
     .top = Frame1.top
     .left = Frame1.left
     .hieght = Frame1.hieght
     .width = Frame1.Width
  End With

  Frame1.visible = false  
  Frame2.visible = true

End Sub
0
 
AzraSoundCommented:
you could also use a control array, which is always good practice whenever it can be used b/c it saves memory (in this case its minimal but i'm just making noise)
also the way you make it sound you are adding this frame right on top of the other frame at design time?  where are the controls on the second frame?  seems they would be getting pretty cluttered at this point.  are you just changing captions or other simple properties?  just curious as to the use of the two frames...
0
 
jusclevCommented:
Hi Sankar,

Try this: It switches containers, then moves the remaining frame top the desired position. I used it twice and it worked fine.

Private Sub Event_Name (args)

Set Frame2.Container = Frame1.Container

With Frame1
    Frame2.Move .Left, .Top, .Width, .Height
    .Visible = False
End With

Frame2.visible = true
End Sub
0
 
Sankar030999Author Commented:
Adjusted points from 50 to 100
0
 
Sankar030999Author Commented:
the cut and paste mtd wormed fine.
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.