Solved

2 frames in a form

Posted on 2000-05-14
10
169 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now