VBA基本函数返回null

时间:2015-07-29 11:37:35

标签: access-vba

我有一个非常基本的功能,即返回符号,如" =",">","<",&# 34;> ="和"< ="它只返回一个空值。任何想法?

Function Lookup_Symbol(search_Name As String) As String
    Lookup_Symobl = DLookup("[Symbol]", "[Search_Names]", "[Search_Name]= '" & search_Name & "'")
End Function

当我执行Debug.print DLookup("[Symbol]", "[Search_Names]", "[Search_Name]= '" & search_Name & "'")时,它将返回=

1 个答案:

答案 0 :(得分:1)

因为您的函数中拼错了Lookup_Symbol。它应该是:

Function Lookup_Symbol(search_Name As String) As String
    Lookup_Symbol = DLookup("[Symbol]", "[Search_Names]", "[Search_Name]= '" & search_Name & "'")
End Function

如果您在模块顶部有Option Explicit,那么您可以更容易地发现这一点;然后会告诉你变量Lookup_Symobl没有定义。