Shortcut Menu Functions

EricTheRed

Registered User.
Local time
Today, 18:44
Joined
Aug 7, 2003
Messages
27
After much fruitless searching, I've broken down and decided to start a topic. This issue has been mentioned before on these forums, but never answered, so here goes:

I have a shortcut menu, "smnuContact", which appears when a user right-clicks on a series of search results. I have the items in the menu linked to code bound to the form. Here's the strange thing: whenever I click one of the menu items, the function code is run three times! Nothing I've done, short of some very ugly hacks, has eliminated the problem. Help!

- Eric
 
I've experienced the same problem of a function being executed repeatedly on certain events. I didn't track down the exact problem because the multiple execution was inconsequential to the programn and no appreciable runtime degredation was experienced.

However, it appears that this problem was precipitated by the function being placed on an event that gets repeated under certain circumstances.

Sorry I can't be more specific, but am aware that it's occurring on one of my appliations as a result of debugging some code.
 
Unfortunately, I cannot simply ignore the behaviour. I have a feeling that my end-users will be rather annoyed to have their reports printed three times!

As for the event repeating, I've put the function under the OnAction property of the menu item. I see no logical reason for the code to be repeatedly run, but...

If worst comes to worst, however, I could always do something like:
PHP:
Dim count As Integer
Public Function MenuClickThingie()
    count = count + 1
    If Count = 3 Then
        'Run the code now. **Very ** ugly hack!
    End If
End Function
 
The cause, but not the solution...

It appears that, when using the OnAction property of a popup menu, the function breaks and is called multiple times (in my case, 3) if the function calls a control on a form that cause an event (like Form_Current, or the BeforeUpdate or AfterUpdate of a control).
This is damn ugly and I have no logical explanation... but knowing the cause solves half the problem, right? So, anybody can solve the second half??? Please??? :p
 
Solution!!!

Update!
It appears that this is known problem that is carried around since Access '97.
Here is Microsoft's sorry excuse, along with a solution : Microsoft support
In short, put the function you call from the OnAction property in a class module, not in a form's module.
Stupid bugs! Took two hours of my time I never gonna get back! I should bill Bill for this!!! :D
 

Users who are viewing this thread

Back
Top Bottom