我正在尝试从另一个表[流程订单]中获取记录并将其放入一个带有日期的新表(NewTableName),但我不断得到'参数太少。预计1'。我让它工作并基于[Process No] = txtProc或之前的某些东西传递一个字段,但无法让它传递我需要的所有字段。
Dim strSQL As String
Dim NewTableName As String
NewTableName = "[Process Order-Oven " & Format(Date, "DD-MM-YYYY") & "]"
strSQL = "SELECT [Run No], [Product ID], [Process No], [Product Description], " & _
"[Good Product Produced] INTO " & NewTableName & _
" FROM 'Process Order' WHERE [Process No] = txtProc.Value"
CurrentDb.Execute strSQL, dbFailOnError
答案 0 :(得分:2)
[您需要连接txt值。我希望这是一个数字。如果没有将它括在单引号之间。
Dim strSQL As String
Dim NewTableName As String
NewTableName = "[Process Order-Oven " & Format(Date, "DD-MM-YYYY") & "]"
strSQL = "SELECT [Run No], [Product ID], [Process No], [Product Description], " & _
"[Good Product Produced] INTO " & NewTableName & _
" FROM [Process Order] WHERE [Process No] = " & txtProc
CurrentDb.Execute strSQL, dbFailOnError
答案 1 :(得分:1)
我从字符串中删除了txtProc.Value,以便提供该值 - 我假设它是一个文本字段,因此用引号括起来。这应该解决“参数太少”的错误。我还更改了“流程订单”以使用括号分隔符。
strSQL = "SELECT [Run No], [Product ID], [Process No], [Product Description], " & _
"[Good Product Produced] INTO " & NewTableName & _
" FROM [Process Order] WHERE [Process No] = '" & txtProc.Value & "'"