VBA错误:运行时错误'2147217900(80040e14)':')附近的语法不正确

时间:2015-12-09 22:22:20

标签: excel-vba vba excel

大家好,我可以帮助我解决此错误消息,我的代码在这里:

Sub rvt(ByVal make, ByVal model, ByVal ModelYear, ByVal mm, ByVal yy, ByRef arrTerm(), Optional ByVal Country = "US")
Dim strsql As String, strterm As String
Dim outcell As Range

If Country = "US" Then GDF = "ALG"
If Country = "CA" Then GDF = "CBB"

strterm = ""
For i = 1 To UBound(arrTerm)
    If i <> UBound(arrTerm) Then strterm = strterm & arrTerm(i) & ", "
    If i = UBound(arrTerm) Then strterm = strterm & arrTerm(i)
Next

strsql = "SELECT [" & GDF & "GuideResidNew_MMMY]" & _
         "FROM [ResidualValueForecast].[GDF].[" & GDF & "Guide_New_MMMY]" & _
         "WHERE RVI_Make='" & make & "' and RVI_Model='" & model & "' and modelyear='" & ModelYear & "' and guidedate='" & yy & "-" & mm & "-01' and term in (" & strterm & ") " & _
         "ORDER by term"
Sheets("DATA").Range("RVT[" & GDF & "]").ClearContents
Set outcell = Sheets("DATA").Range("RVT[" & GDF & "]")

Call SQLconn(strsql, "ResidualValueForecast", outcell)
If ok_SQL = False Then MsgBox "No " & GDF & " Residuals found for " & make & "-" & model & "-" & ModelYear & vbNewLine & "Please check the table in the server!", vbInformation

End Sub

0 个答案:

没有答案