我正在尝试将查询数据集中的前x个记录插入到表中。但是我一直得到运行时错误'3061'参数太少。预期1.我尝试过一些事情,但没有任何区别。
Private Sub UpdateGA_Click()
Dim dbs As DAO.Database
Dim strSQL As String
Dim rounds As Integer
Dim playerid As Long
Set dbs = CurrentDb
rounds = Me.NoOfScores.Value
playerid = Me.lngPlayerID.Value
strSQL = "INSERT INTO [tbl_TopRounds] ( [lngPlayerID], [lngRoundID], [dblPlayedTo], [dteRoundDate]) " & _
" SELECT TOP " & Me.NoOfScores.Value & " [lngPlayerID], [lngRoundID], [dblPlayedTo], [dteRoundDate] FROM qry_LastRounds" & _
" WHERE [lngPlayerID] = " & Me.lngPlayerID.Value & _
" ORDER BY [dblPlayedTo], [dteRoundDate] DESC;"
dbs.Execute strSQL
End Sub
我期待x(基于表单参数)记录将被写入tbl_TopRounds。
任何帮助都将不胜感激。
答案 0 :(得分:0)
通常,此错误表示您在字段名称中出错。在最后一个命令上设置断点,运行sub,打开立即窗口并键入?strSQL
。复制收到的SQL文本并尝试在查询生成器中运行它,它将显示表中不存在的列名。错误可能出在查询qry_LastRounds
中,请先打开