如何修复“表达式中的未定义函数'xxx'”(SQL查询中的Excel函数)

时间:2019-07-09 13:37:21

标签: sql excel vba

我正在尝试对SQL查询调用Excel函数,但我不断收到相同的错误:“表达式中的未定义函数xxx”。

我仅出于客户选择而使用Excel。

我检查了参考文献是否缺失, 我的函数在有效的带有Option Explicit的模块中,并声明为Public。 而且我确定我有一个返回值。

谢谢您的时间

有我的功能

Public Function CalculRamasseCarriste(ByVal lng_QTE As Integer, ByVal str_CodeArticle As String, ByVal lng_QTEmax As Integer) As Boolean

    Static lng_cumulQTE         As Integer
    Static str_Text             As String
    Static bln_Prendre          As Boolean


    If str_Text = "" Then
        str_Text = str_CodeArticle
    ElseIf str_Text <> "" Then
         If str_Text <> str_CodeArticle Then
            str_Text = str_CodeArticle
            lng_cumulQTE = 0
         End If
    End If

    lng_cumulQTE = lng_cumulQTE + lng_QTE


    If lng_cumulQTE < lng_QTEmax Then
        CalculRamasseCarriste = True
        bln_Prendre = True
    ElseIf lng_cumulQTE >= lng_QTEmax And bln_Prendre = True Then
        CalculRamasseCarriste = True
        bln_Prendre = False
    Else
        CalculRamasseCarriste = False
    End If

End Function

这是我的查询:

    Return_Qry_Ramasse = "SELECT T1.[Adresse], T1.[N° Support], T1.[Code_Article], T1.[Libellé_article] " & _
                         " FROM [V_Stock$] as T1 " & _
                         " LEFT JOIN [Cmd$] as T2 on T1.[Code_Article] = T2.[Code_Article] " & _
                         " WHERE CalculRamasseCarriste(T1.[Nb Box-Colis / Pal], T1.[Code_Article], T2.[UVC_cmd])= True " & _
                         " ORDER BY [Code_Article], [Adresse], [N° Support]"

0 个答案:

没有答案