Link to home
Start Free TrialLog in
Avatar of Sankar030999
Sankar030999

asked on

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
Avatar of ofirg
ofirg

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.
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.
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
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).
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
ASKER CERTIFIED SOLUTION
Avatar of wsh2
wsh2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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...
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
Avatar of Sankar030999

ASKER

Adjusted points from 50 to 100
the cut and paste mtd wormed fine.
thanks