I found 另一个答案在这里 https://stackoverflow.com/questions/5445062/run-time-error-3061-too-few-parameters-expected-1-access-2007#这解决了这个问题,但对我没有帮助。我检查了我尝试引用的查询,没有发现任何字段有问题。我还尝试了如何声明和设置对象和东西,但这也不起作用。
Dim dbsCurrent As DAO.Database
Dim rst As DAO.Recordset
Set dbsCurrent = CurrentDb
Set qdf = CurrentDb.QueryDefs("qry_FilmZip")
Set rst = qdf.OpenRecordset 'The error points to this line
rad_full = rst!radius_full
MsgBox ("rad_full:" + rad_full)
Update:我尝试为 .OpenRecordSet 方法提供查询名称,如下所示:Set rst = qdf.OpenRecordset("qry_FilmZip")
...但现在它给了我一个新的错误:Run-time error 3421: Data type conversion error
。有人知道发生了什么事吗?错误指向同一行。
我找到了如何解决第二个错误。事实证明我必须这样做
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
...但我不明白这到底是做什么的。有人可以启发我吗?
The SQL:
SELECT
tbl_FilmZipInfo.ID,
tbl_FilmZipInfo.item,
tbl_FilmZipInfo.qty_per_unit,
tbl_FilmZipInfo.unit_of_measure,
tbl_FilmZipInfo.radius_core,
tbl_FilmZipInfo.radius_full,
tbl_FilmZipInfo.Lf_value_for_zipper,
tbl_FilmZipInfo.S_value_for_zipper,
tbl_FilmZipInfo.film_or_zip,
tbl_FilmZipInfo.Comments,
tbl_FilmZipInfo.physical_description
FROM
tbl_FilmZipInfo
WHERE
(((tbl_FilmZipInfo.item)=[Forms]![frm_FilmZip]![Text314]));