Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can't change the properties of a MDI form

Posted on 1998-10-08
7
Medium Priority
?
193 Views
Last Modified: 2010-04-30
I have a program that uses a MDI form. I try to change that forms properties just like any other object like
formname.proprety.value or for a better example
form1.caption = "Test"
I get a run time error 426; Only one MDI form allowed.
What should I do? Thanks
0
Comment
Question by:xer_soft
7 Comments
 
LVL 3

Expert Comment

by:vmano
ID: 1438928
Error 426 - Only one MDI Form allowed

A project can only have one MDIForm. This error has the following causes and solutions:

You tried to load a file containing an MDIForm into a project that already has an MDIForm in it. Remove the file containing the loaded MDIForm before loading another.

You tried to load a second instance of an MDIForm created with a Dim or Set statement. You can only create one instance of an MDIForm in a project.

0
 
LVL 1

Expert Comment

by:CarlosJac
ID: 1438929
If you has generated the app with Application Wizard:

use fMainForm and not use the mdiform name.
Example:

fMainForm.caption = "Test"


Why?

The app wizard has created a module with sub main:

Sub Main()
    Set fMainForm = New frmMain
    fMainForm.Show
End Sub

If you attempt use frmMain, VB attempt to load the mdiform , but the mdi is already loade.

Good Luck

Sorry, my english is very bad.

0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1438930
The problem is the way you are referring to the form.  I would have to look at the code to tell you exactly what is going on.  Here is a workaround, though.  It uses the Forms Collection to change the caption:

Dim i as Integer

For i = 0 To Forms.Count
    If Forms(i).Name = "MDIForm1" Then
        Forms(i).Caption = "Test"
        Exit For
    End If
Next i

Just change the name in quotes to the name of your MDI form.

Later,
Martin

0
Industry Leaders: 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 1

Author Comment

by:xer_soft
ID: 1438931
CarlosJac please put you answer down as the answer for as you have helped me the most. Thanks much your way worked great and was very easy. Your english was not that bad! Thanks again!
0
 
LVL 1

Accepted Solution

by:
CarlosJac earned 800 total points
ID: 1438932
If you has generated the app with Application Wizard:

use fMainForm and not use the mdiform name.
Example:

fMainForm.caption = "Test"


Why?

The app wizard has created a module with sub main:

Sub Main()
    Set fMainForm = New frmMain
    fMainForm.Show
End Sub

If you attempt use frmMain, VB attempt to load the mdiform , but the mdi is already loade.

Good Luck

Sorry, my english is very bad.

0
 
LVL 1

Author Comment

by:xer_soft
ID: 1438933
Thanks a bunch!!!!!!!
0
 
LVL 1

Expert Comment

by:CarlosJac
ID: 1438934
not at all
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

876 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