0

我有以下无法运行的查询。

任何人都可以建议我其他人的正确顺序,如果我看不到它???

我的查询是....

select case sourcefields("Query8111.Job Code and Stage")


Case"703"
currentfield = "T703"
Case"801"
currentfield = "T801"

case else 
if right(rtrim(sourcefields("Query8111.Job Code and Stage")),4) = "-99C" then 
currentfield = "T020"
ElseIf
right(rtrim(sourcefields("Query8111.Job Code and Stage")),3) = "EXT" then 
currentfield = "T015"
else
currentfield = "T010"

end if
end select

我的错误信息是:-

在此处输入图像描述

所有帮助表示赞赏

4

2 回答 2

1

很久没用VB了,这就是你需要的吗?

Dim Q As String
Q = RTrim(sourcefields("Query8111.Job Code and Stage"))   

Select Case Q
Case "703"
currentfield = "T703"
Case "801"
currentfield = "T801"
Case Else
    If Right(Q, 4) = "-99C" Then
    currentfield = "T020"
    Else
        If Right(Q, 3) = "EXT" Then
        currentfield = "T015"
        Else
        currentfield = "T010"
        End If
    End If
End Select
于 2013-11-13T16:24:42.320 回答
0

在我看来你ElseIf是错的。条件语句在同一行。我也认为你的意思是Strings.Right,不是right

Select Case sourcefields("Query8111.Job Code and Stage")

Case"703"
    currentfield = "T703"
Case"801"
    currentfield = "T801"

Case Else
    If Strings.Right(rtrim(sourcefields("Query8111.Job Code and Stage")),4) = "-99C" then 
         currentfield = "T020"
    ElseIf Strings.Right(rtrim(sourcefields("Query8111.Job Code and Stage")),3) = "EXT" then 
         currentfield = "T015"
    Else
         currentfield = "T010"    
    End If
End Select
于 2013-11-13T17:27:16.777 回答