Solved

Can't change the properties of a MDI form

Posted on 1998-10-08
7
185 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:xer_soft
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks a bunch!!!!!!!
0
 
LVL 1

Expert Comment

by:CarlosJac
Comment Utility
not at all
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

762 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

6 Experts available now in Live!

Get 1:1 Help Now