• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Displaying popup menus on a child form from and MDIForm

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
phil_walker
Asked:
phil_walker
1 Solution
 
DocMCommented:
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
 
phil_walkerAuthor Commented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now