Problem using EVAL function

Schof

Registered User.
Local time
Today, 04:41
Joined
Nov 15, 2002
Messages
44
When I use the EVAL function to execute a procedure in a form it executes the procedure twice. Does anyone know of a workaround or a fix for this?

For example:


On Click: =eval(Form_AfterUpdate)

where Form_AfterUpdate is a public procedure.


I tried to use the EVAL function in a popup menu to execute a procedure in a form but had the same result. Instead I had to use the SendKeys function but the problem with that is it only works for control with shortcuts defined.
 
That procedure was just an example. In my application I have created popup menus and have set the action as
"=processShortcutMenu()". I have defined that function in a module as:


Public Function processShortcutMenu()
Dim cmdbarCtl As CommandBarControl

Set cmdbarCtl = CommandBars.ActionControl
Eval ("Forms(" & Chr$(34) & application.CurrentObjectName & Chr$(34) & ")." & cmdbarCtl.Tag)
End Function

The commandbar tag is the name of the procedure in the form that I want to run. This works but again, it runs mulitple times.

I am also trying to use this concept in other areas other than popup menus so it is very important for me to figure out how to do this.
 
I knew there was a way to do it. Enjoy!!!

Public Function processShortcutMenu()
Dim frm As Form
Dim cmdbarCtl As CommandBarControl

Set cmdbarCtl = CommandBars.ActionControl
Set frm = Forms(application.CurrentObjectName)

CallByName frm, cmdbarCtl.Tag, VbMethod
End Function
 

Users who are viewing this thread

Back
Top Bottom