Access MVP (2010-2015)

oOo.oOo.oOo.oOo.oOo.oOo

To Few Parameters Expected n…

…while using db.OpenRecordset with a Parameter…

Change this…

Set rst = db.OpenRecordset(“qryYourQuery”, dbOpenSnapshot)

To this, for TEXT…

Set rst = db.OpenRecordset(“SELECT * FROM qryYourQuery WHERE tblYourTable.ytYourField= ‘” & [Forms]![frmYourForm]![txtYourTextBoxOnForm] & “‘”)

Or, if your field is NUMERIC…

Set rst = db.OpenRecordset(“SELECT * FROM qryYourQuery WHERE tblYourTable.ytYourField = ” & [Forms]![frmYourForm]![txtYourTextBoxOnForm])

Or, if your field is a DATE…

Set rst = db.OpenRecordset(“SELECT * FROM qryYourQuery WHERE tblYourTable.ytYourField= #” & [Forms]![frmYourForm]![txtYourTextBoxOnForm]”#”)

Make a copy of *qryYourQuery* first and, then, remove the Parameter from your *qryYourQuery*.

 2,320 total views,  1 views today

Comments are closed.