Eval Function (3 times)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

I'm using the "Eval" Function to evaluate an expression (It clicks on a buton)
Eval("Forms!ReportsMenuSub.CBSum_Click"), CBSum_Click is a Public sub in ReportsMenuSub Form

It's running 3 times, it evaluates the expression 3 times.
It's very wierd

Any advice will be very appreciated

Thanks in advanc
G.Hadda
 
That is actually a known problem. Are you running this code from a custom
menu?

You also don't explain why you are using eval() ?

You have several choices:

1) Move the code to a standard module

2) Add a public function to the main form that goes:

Public Function MainCallSub

Call me!ReportsMenuSub.Form.CBSum_Click

End Function

And then use:

eval("=MainCallSub()")

(note by leaving OUT the forms qualifier..then the code does NOT run 3
times).

By the way, if not using custom menus...but just some button code, then
there is no need to use Eval anyway. You can go:

Call me!ReportsMenuSub.Form.CBSum_Click()
 
Just a word of thanks to people like Albert Kallal that take time out of their busy days to help us all on here. He and others like him have been a huge help to me in the past.
 
Thanks for your response, but I'm having another problem now

what I want to do is the following
I have a Standard Module

Module name: Reports_modul

Public Sub Report1(
--
End Su

Public Sub Report2(
--
End Su

and from another Form I'm calling
Eval ("Call Reports_module." & var & "()") where var is a value fom a listbox (Report1 or Report2

For testing, I tried to create a public function

Public Function CallReport(
Call Reports_module.Report1(
End Functio

and call

Eval ("=CallReport()"

Nothing Occured

what did I miss
and sorry I'm wasting your time

Thanks in advance

Regards
G.Hadda
 
Back
Top