?
Solved

Displaying popup menus on a child form from and MDIForm

Posted on 2003-03-31
2
Medium Priority
?
229 Views
Last Modified: 2010-04-07
Hi,

I'm having problems displaying a menu located on an MDIform, as a popup menu on a child from. I am using Visual Basic v6.

I have created a menu system on the MDIForm ('frmMain') with a drop down menu called 'popAdd' which is hidden. I am attempting to display the menu on a child form called 'frmOrder'. When I click a button called 'cmdAdd', on 'frmOrder', I wish to display 'popAdd' as a popup menu next to the button.

I don't want to create a menu system on the child form because this will replace the menus on the MDIForm which I need to remain fixed.

Here is the code from the button on 'frmOrder' (child) that attempts to display the popup menu on 'frmMain' (MDI)...

Private Sub cmdAdd_Click()
    PopupMenu frmMain.popAdd, , cmdAdd.Left + cmdAdd.Width, cmdAdd.Top
End Sub


I have searched experts-exchange.com and the solutions I can find suggest that my code should work correctly, however, I am recieving a runtime error '426' - 'Only one MDI form allowed'.

Has anybody got any ideas what is causing the problem and how to get around it?

Thanks for any help,
Phil Walker.
0
Comment
Question by:phil_walker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
DocM earned 225 total points
ID: 8238895
Hi,
You probably have a Sub Main like this one:
Sub Main()
    Set fMainForm = New frmMain
    fMainForm.Show
End Sub

So your MDI Form's name is fMainForm and not frmMain.
Try to replace
Private Sub cmdAdd_Click()
   PopupMenu frmMain.popAdd, , cmdAdd.Left + cmdAdd.Width, cmdAdd.Top
End Sub
by
Private Sub cmdAdd_Click()
   PopupMenu fMainForm .popAdd, , cmdAdd.Left + cmdAdd.Width, cmdAdd.Top
End Sub
0
 

Author Comment

by:phil_walker
ID: 8239073
DocM,

That works a treat! I can't believe I missed it.

Thanks very much for pointing out the solution.

Regards,
Phil Walker
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

764 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