MS Access vba, open select query with parameters, run-time 3065 cannot execute a select query -
i getting frustrated trying open select query "parameter" set. suspect building query wrong. want form unbound date textbox user input date (i have this). want date passed prestored parameter select query , query opens. if open query manually asks [compare date] expected. when use form, click button open query qdf.execute fails.
fictitious query demo
parameters [compare date] datetime; select [compare date] compare_date; i know "parameters" in clause but, again, query works if run manually.
then below calling code
private sub btnrunreport_click() const pstr_currency_qry string = "query12" const pstr_data_param string = "compare date" dim db dao.database: set db = currentdb() dim qdf dao.querydef set qdf = db.querydefs(pstr_currency_qry) qdf .parameters(pstr_data_param).value = cdate(me.txtcomparedate.value) .execute dbfailonerror ' <<<< fails here .close end ' qdf set qdf = nothing set db = nothing end sub can tell me how fix or come @ different approach query works manually , via form?
you can't use dao execute method select query. why access complains "cannot execute select query."
the parameter issue not relevant here.
decide want result set parameter query returns. if want load recordset, can use querydef's openrecordset method.
Comments
Post a Comment