Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a button on MDI form from Child form 1

Status
Not open for further replies.

zggs90

Programmer
Sep 3, 2001
58
GB
I have a MDI program and the main from has a tool bar with buttons, these butons may be enabled or disabled and I want to change the button (from disabled to enabled depending upon an event in a child form.) I have tried "frmMDI.cmdBuuton.enabled = true" etc but get an error saying "can only have one MDI form".

Any ideas on how this can be achieved?

Regards
 
Your MDI form is probably not named frmMDI (eventhough it looks like it is). Let me explain.

In your VB project, you have forms, modules, class modules, etc...

If you have a form named frmForm1 in the VB Project, it doesn't necessarily have to be called that when the app is running.

In VB, you can do the following...

Dim myForm as frmForm1

Set myForm = New frmForm1
call myForm.Show
Set myForm = Nothing

You probably have your app's startup object something other than frmMdi. It could be Sub Main or possibly a splash screen or login form. I would bet that somewhere in there, you are creating a new instance of the MDI form (with a different name), and then showing it. Now, the name you refer to the form is different than the name it appears as in VB's project explorer.

I hope this helps. If not, let me know.
 
gmmastros, you are a genius.

I had used the Project Wizard to create the MDI program and it creates the sub Main and includes the statement "Set fMainForm = New frmMain" and was the root of my problem. I had not even looked at the coding in Main.

Many thanks for a staight forward explanation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top