Solved

2 frames in a form

Posted on 2000-05-14
10
173 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:Sankar030999
10 Comments
 
LVL 1

Expert Comment

by:ofirg
ID: 2808369
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
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2808370
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
 
LVL 3

Expert Comment

by:fibdev
ID: 2808373
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:fibdev
ID: 2808377
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
 
LVL 3

Expert Comment

by:fibdev
ID: 2808378
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
 
LVL 14

Accepted Solution

by:
wsh2 earned 100 total points
ID: 2808395
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 2808513
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
 

Expert Comment

by:jusclev
ID: 2809159
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
 

Author Comment

by:Sankar030999
ID: 2812946
Adjusted points from 50 to 100
0
 

Author Comment

by:Sankar030999
ID: 2812947
the cut and paste mtd wormed fine.
thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question