Close Popup menu form

Russ9517

Registered User.
Local time
Today, 03:35
Joined
Sep 15, 2006
Messages
30
I've created a popup menu form to be loaded when you cick on another form. I need to know how to get the popup menu form to close when you click off it. I've tried using lostfocus and deactivate but that didn't work. Modal is set to no. What code should i use and where would it go?
 
Last edited:
If you want the form to close after the user has clicked on it ( and thereby clicked off the popup menu ) you could assign a 'close' macro to the form property 'OnClick' rather than assigning it to the popup menu on 'LostFocus'.

Alternatively, you could put a submit button on the form that is in fact a 'close form' button.

Hope this helps.
 
This would be nice if it worked but it doesn't.
Neither LostFocus nor OnClick can be persuaded to fire if you click away from the form, whether modal is set or not. The solution I use is to have a 'Hide' item at the bottom of the menu (put a line above this and it looks like a normal windows pup-up menu item) plus a timer. :(
 
Simple Software Solutions

Hi
MS has a function called IsLoaded("Your Form Name")
It loops through all the forms in the mdb until it finds the form name you have passed to it and checks to see if it is loaded and returns a boolean response.

What you could do is to set a Call on your main form when it either gets focus or any controls receives the focus and perform the following

If IsLoaded("PopUpFormName") = True Then
DoCmd.Close acForm, "PopUpFormName"
End If
 
I like your idea! If you use the pop-ups on more than one form you do have to add code to each form. In my case the object underneath the popup is a grid where I am implementing click and drag operations so it is a bit more complicated. Might still try it some time though. IsLoaded was introduced in Access 2000. Before that you had to implement your own (shows age...)
 
What about simply using a CLOSE form command button on the Pop-Up form? The command button, as part of the VBA code would have a DOCMD.GOTOCONTROL "SOMECONTROL". Since you are issuing a command through the onclick event it shouldn't matter if its on the pop-up form itself or on another form.
 
The point of this discussion is trying to emulate a 'right-click' menu. Those menus have no buttons and when you click on something else they automatically close.

What about simply using a CLOSE form command button on the Pop-Up form? The command button, as part of the VBA code would have a DOCMD.GOTOCONTROL "SOMECONTROL". Since you are issuing a command through the onclick event it shouldn't matter if its on the pop-up form itself or on another form.
 
Wish to thank DCrake for the IsLoaded idea...works great on my DB
Inserted it just before Exit Command Click
 
Simple Software Solutions

Thanks Thunderbolt

Your appreciation is valued as many people who find solutions forget to reply that it actually worked:D. Reputations can be good or bad so by letting other know helps all.

David
 

Users who are viewing this thread

Back
Top Bottom