Solved

Can't change the properties of a MDI form

Posted on 1998-10-08
7
187 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 200 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 / DAO 3.6 / run time error: Couldn't find installable ISAM 7 93
Excel - Save a copy of work book 13 84
Protecting vb6 & .Net code Obfuscation 18 121
RUNRMTCMD from AS/400 12 43
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

816 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

8 Experts available now in Live!

Get 1:1 Help Now