|
-
Jan 19th, 2000, 02:10 AM
#1
Thread Starter
Junior Member
I am trying to load forms into memory using a generic load form routing and I keep getting a "Type Mismatch Error". I would like to do something like the following:
Function fcnLoadForm(strFormName As String)
Forms(strFormName).Load
End Function
Or
Function fcnLoadForm(strFromName As String)
Load strFormName
End Function
I know that I should be able to do something like this, but at this moment in time it is eluding me.
Also I am noticing and confirmed with MSDN that a Form is only in the Forms Collection after it is loaded into memory.
Any help would be greatly appreciated.
Thank you
Candu
-
Jan 19th, 2000, 02:52 AM
#2
Try this:
Code:
Private Sub Command1_Click()
LoadForm "Form3", True
End Sub
Sub LoadForm(ByVal Formname As String, Optional ByVal bShow As Boolean = False)
Dim iIndex As Integer
'Add the Form to the Forms Collection
'>>> Formname MUST exist to add it to the Collection <<<
Forms.Add Formname
'Find the Index of the Form we just added
For iIndex = 0 To Forms.Count - 1
If Forms(iIndex).Name = Formname Then Exit For
Next
If iIndex < Forms.Count Then
'If the Form Existed Then Load it
Load Forms(iIndex)
If bShow Then Forms(iIndex).Show
End If
End Sub
I included the Optional Parameter bShow so you can Show the Form after loading it if you want to.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Jan 19th, 2000, 08:49 PM
#3
Thread Starter
Junior Member
Thank you very much Araon. Your solution works like a charm.
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
|