|
-
May 28th, 2002, 03:56 PM
#1
Thread Starter
Member
open form
how do i open another form
-
May 28th, 2002, 03:56 PM
#2
PowerPoster
-
May 28th, 2002, 03:58 PM
#3
Member
whatever the form name is,
form1 for instance
form1.show.
and say for instance u want to input something in the other form?
(open it first ^)
then do:
form1.label1.caption = "hello world!"
it wont work if the other form isn't open.
-
May 28th, 2002, 04:04 PM
#4
Originally posted by Interesting
it wont work if the other form isn't open
Not true. You can do it even when the form is unloaded and disabled.
-
May 28th, 2002, 04:12 PM
#5
PowerPoster
Well
Stiletto : Won't that still in turn load the form into memory? Setting a property on an object on another form does load the from, right?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
May 28th, 2002, 04:18 PM
#6
No.
Lets say I have 2 forms, Form1 and Form2. The start up form is Form1.
If i do this:
VB Code:
Form2.Label1.Caption = "Something"
It wont load Form2. And I can do it while Form2 is unloaded or disabled
-
May 28th, 2002, 04:23 PM
#7
PowerPoster
Well
ut doesn't it load it into memory?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
May 28th, 2002, 04:34 PM
#8
I'm sure that you can do it even if the form is unloaded or disabled, and it wont load the form into memory.
This way allows you to set all control as you want and then load the form.
-
May 28th, 2002, 04:39 PM
#9
PowerPoster
Well
Yes. I load the form, set controls, the display. I never have just set a control on a form, kinda like I would use it in the future. I only set the controls on ther form that I would load up next....
Or am I missing something?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
May 28th, 2002, 04:40 PM
#10
PowerPoster
No, Stilleto, you're wrong about that. Any time you reference a form, it gets loaded. See your MSDN documentation.
Here's what I do to find out if a form is loaded without referencing specific forms. First, I give each form a unique tag. Then I check it like this:
VB Code:
If FormLoaded ("frmOptions", False) then
' do whatever
end if
Public Function FormLoaded(sTag As String, RestoreWindow As Boolean) As Boolean
Dim frm As Form
' Loops through loaded forms and searches for a matching tag
' Restores window if RestoreWindow argument is true
' Form will not get loaded if it is not loaded already.
On Error GoTo errHandler
Hourglass True
For Each frm In Forms
If frm.Tag = sTag Then
FormLoaded = True
If RestoreWindow Then
frm.WindowState = vbNormal
frm.ZOrder 0
End If
Exit For
End If
Next frm
Hourglass False
Exit Function
errHandler:
LogError Error, Err, vbNullString, "bForms.FormLoaded"
Hourglass False
End Function
-
May 28th, 2002, 04:43 PM
#11
You first sets all controls and then show/load the form.
VB Code:
sMsg = "Hello User, welcome back to your application"
Form1.Label1.Caption = sMsg
Form1.Show
'This will load form1 when Label1 is already set.
-
May 28th, 2002, 04:45 PM
#12
-= B u g S l a y e r =-
Originally posted by Stiletto
No.
Lets say I have 2 forms, Form1 and Form2. The start up form is Form1.
If i do this:
VB Code:
Form2.Label1.Caption = "Something"
It wont load Form2. And I can do it while Form2 is unloaded or disabled
in form1
VB Code:
Private Sub Command2_Click()
Form2.Label1.Caption = "Test"
End Sub
in form2
VB Code:
Private Sub Form_Load()
MsgBox "Loading"
End Sub
its loading
-
May 28th, 2002, 04:51 PM
#13
OMG...*Runs away* 
-
May 28th, 2002, 04:52 PM
#14
K so it will load the form but you can do it even when the form is unloaded or disabled.
-
May 28th, 2002, 04:54 PM
#15
PowerPoster
Peet is right, Stilleto. A lot of folks don't understand this and it screws them up down the road when they need things to happen in a certain order. Here's an example:
VB Code:
Sub Main ()
frmDatabase.Caption = "My awesome database app"
frmDatabase.Filename = "c:\Program Files\AwesomeDB\db.mdb"
frmDatabase.Show
End Sub
' frmDatabase
Sub Form_Load ()
' Open the database here. You'll find the filename isn't set
' yet because the form_load event happened when you set
' the caption, but before you set the filename.
End Sub
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
|