评估错误2431 [英] Eval error 2431

查看:66
本文介绍了评估错误2431的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eval调用函数。它在一个表单模块中运行,在
响应一个按钮OnClick。


strCall =" Forms!frmSchedule.eval" &安培; strSName(0)& "()"

On Error Resume Next

n = Eval(strCall)

出于测试目的,strSName(0)是always =" LoanType"


函数evalLoanType运行正常,并且不会产生错误。


但是,当控制返回时对于上面的调用路由,n始终是

Empty和Err.Number = 2431,即您输入的表达式

包含无效语法。


可以有人帮我解决这个问题,以便它返回正确的值

函数,并且不会产生错误吗?错误值是一个问题,因为我仍然需要陷入变量名为

的函数不存在的情况。


谢谢,


Ray



函数evalLoanType()作为整数

开错误GoTo eLT_Err

如果不是正面信息(Me!ScheduleNoOfParties)那么

MsgBox请输入参加人数。,vbInformation,数据

条目"

evalLoanType = -1

否则

evalLoanType = 0

结束如果

eLT_Exit:

退出功能

eLT_Err:

MsgBox Err.Description& vbCrLf& vbCrLf& 无法评估数量

的派对。继续eLT_Exit

结束功能

I am calling a function using eval. It runs in a form module, in
response to a button OnClick.

strCall = "Forms!frmSchedule.eval" & strSName(0) & "()"
On Error Resume Next
n = Eval(strCall)
For the purposes of testing, strSName(0) is always = "LoanType"

The function evalLoanType runs ok, and doesn''t generate an error.

However, when control return to the calling routing above, n is always
Empty and Err.Number = 2431, that is, "The expression you entered
contains invalid syntax."

Could anybody help me resolve this so that it returns the correct value
of the function, and doesn''t produce an error? The error value is a
problem because I still need to trap situations where a function named
by the variable doesn''t exist.

Thanks,

Ray


Function evalLoanType() As Integer
On Error GoTo eLT_Err
If Not PositiveInteger(Me!ScheduleNoOfParties) Then
MsgBox "Please enter the Number of Parties.", vbInformation, "Data
Entry"
evalLoanType= -1
Else
evalLoanType= 0
End If
eLT_Exit:
Exit Function
eLT_Err:
MsgBox Err.Description & vbCrLf & vbCrLf & "Cannot evaluate number
of parties." Resume eLT_Exit
End Function

推荐答案

OTTOMH


公共函数evalLoanType()作为整数


n = Form_frmSchedule.evalLoanType()

OTTOMH

Public Function evalLoanType() As Integer

n = Form_frmSchedule.evalLoanType()


谢谢Lyle!


可悲的是,它并没有结合。 Eval似乎只在你将它引用为Forms!FormName.functionname()时才运行该函数。


如果你还有其他东西OTTOYH我会是很高兴听见。或者

OTTOAE'H就此而言,


Ray

Thanks Lyle!

Sadly though, it didn''t woik. Eval seems to run the function only if
you have it referenced as Forms!FormName.functionname().

If you have anything else OTTOYH I would be glad to hear it. Or
OTTOAE''sH for that matter,

Ray


I感谢你已经厌倦并报告但我没有写过关于

Eval。我写了关于


1.确保功能是公共的


2.将n的值设置为
$返回的值b $ b Form_frmSchedule.evalLoanType()。

对于非程序员来说,Eval是一个愚蠢的小黑客。无论多少

年(14?)与Access我从未使用过Eval(TTBOMR)。

I appreciate that you have tired and reported but I did not write about
Eval. I wrote about

1.ensuring the function is Public

2. setting the value of n to that returned by
Form_frmSchedule.evalLoanType() .

Eval is a silly little hack for non-programmers to use. In however many
years (14?) with Access I have never used Eval (TTBOMR).


这篇关于评估错误2431的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆