|
-
Jun 17th, 2000, 10:23 PM
#1
Thread Starter
_______
I open form1 (nag), run it's code, and then
I want to unload it and load the main form.
How do I load form2
if I try this
unload form1
load form2
it doesn't work
I know of visible and invisible but that doesn't instigate the form load event..
how can I open form2 and run the form load
or do I have to use the visible and invisible and then call the form load event after it is visible.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 17th, 2000, 10:30 PM
#2
PowerPoster
Originally posted by HeSaidJoe
I open form1 (nag), run it's code, and then
I want to unload it and load the main form.
How do I load form2
if I try this
unload form1
load form2
it doesn't work
I know of visible and invisible but that doesn't instigate the form load event..
how can I open form2 and run the form load
or do I have to use the visible and invisible and then call the form load event after it is visible.
Just put the form2.Show after the load form2 command.
-
Jun 17th, 2000, 10:33 PM
#3
Your code does run the Form2 Load event, it just doesn't show Form2. Add Form2.Show or Form2.Show vbModal following the load, or just replace the load statement with the show statement since it will cause both to happen.
-
Jun 18th, 2000, 03:53 AM
#4
Member
My 2 cents
I was having the same problem, being very new at this, what worked for me was this:
Form1.Show
Form2.Hide
and the reverse when I wanted to go back to the original form.
Hope this helps, it sure worked for me..... Jim
PS... I attached this code to command buttons.
-
Jun 18th, 2000, 07:03 AM
#5
PowerPoster
Re: My 2 cents
Originally posted by Necromancer
I was having the same problem, being very new at this, what worked for me was this:
Form1.Show
Form2.Hide
and the reverse when I wanted to go back to the original form.
Hope this helps, it sure worked for me..... Jim
PS... I attached this code to command buttons.
Do you mean to hide the Form2 and put the Form1 back to the screen?
Assume Form1 is your startup form.
Code:
Option Explicit
'For the second solution
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private MyForm1Caption As String
Private Sub Form_Load()
MyForm1Caption = Form1.Caption
Me.hide
Load Form2
Form2.Show vbModal
'Or
Form2.Show
End Sub
Private Command1_Click()
Form2.hide
Form1.Show
'Or you can you the FindWindow API to serach for the Form1 and use the ShowWindow API to Display the Form1 on the screen.
Dim xhwnd As Long
xhwnd = FindWindow(0&, MyForm1Caption)
If xhwnd <> 0 Then
ShowWindow xhwnd, SW_SHOWNORMAL
Else
Load Form1
Form1.Show vbModal
End if
End Sub
Hope this will help you. 
[Edited by Chris on 06-18-2000 at 08:07 PM]
-
Jun 18th, 2000, 07:08 AM
#6
Thread Starter
_______
thanks.
should have posted this earlier..
the Form2.show works fine for my purpose
Thanks all...
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|