参数太少。预期<number>。 (错误3061)</number>

时间:2013-04-09 14:15:22

标签: vba

当我运行它时,我在这段代码上收到错误3601,它说参数太少,有什么解决方案吗?

Sub copySDback()
Dim db As DAO.Database

Dim rst As DAO.Recordset

Dim test As String

Dim sdSQL As String

Set db = CurrentDb()
moo = "SD12401064"

sdSQL = "SELECT [Test EUS BL].[Ticket Nbr], [Test EUS BL].[Current Assignment Group],              [Test EUS BL].[ELEVATION STATUS] FROM [Test EUS BL] WHERE ((([Test EUS BL].[Ticket     Nbr])=SD16818515));"
'CurrentDb.OpenRecordset sdSQL

Set rst = db.OpenRecordset(sdSQL, dbOpenDynaset, dbSeeChanges)
If rs.BOF And rs.EOF Then
    rs.Close
    MsgBox "name not found"
End If
Exit Sub

rs.Close
db.Close

1 个答案:

答案 0 :(得分:1)

在您的查询的这一部分

WHERE ((([Test EUS BL].[Ticket     Nbr])=SD16818515))

您似乎在票证 Nbr 之间有多个空格(这可能是格式化问题),但在使用方括号时必须准确无误。此外,与参数所需问题无关,您需要使用单引号括起SD16818515,例如

'SD16818616'

因为它是一个字符串。