我在这一行得到的错误3061参数太少
Set rs = db.OpenRecordset(strSQL)
这是完整的代码
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset ''Requires reference to Microsoft DAO x.x Library
Set db = CurrentDb()
MsgBox Me.LName
MsgBox Me.EmpID
strSQL = "SELECT LastName AS damn FROM [Employees]" & _
"WHERE [Employees].EmployeeID = Me.EmpID"
Debug.Print strSQL
Set rs = db.OpenRecordset(strSQL)
MsgBox rs!damn
Me.LName = rs!damn
MsgBox Me.LName
rs.Close
db.Close
答案 0 :(得分:3)
我能想到的最好的是
"WHERE [Employees].EmployeeID = Me.EmpID"
应该是
"WHERE [Employees].EmployeeID = " & Me.EmpID
另外,HansUp为您提供了一个很好的方法来解决这个问题。