ms access - VBA add parameters to new query def -


this code works fine:

dim db dao.database, rs dao.recordset, qd dao.querydef  set db = currentdb set qd = db.querydefs("query1") qd.parameters("[cou]").value = "be" set rs = qd.openrecordset until rs.eof     debug.print rs!title, rs!country_fk     rs.movenext loop rs.close 

but when try achieve same result creating querydef instead of using existing one, error on qd.parameters line.

set db = currentdb set qd = db.createquerydef qd.sql = "parameters [cou] text ( 255 ); select top 10 title, country_fk dbo_client country_fk=[cou];" qd.parameters("[cou]").value = "be"  set rs = qd.openrecordset until rs.eof ... 

i noticed qd.parameters.count = 0 , qd.parameters.add not allowed.
solution ? thx

your second example should work if give querydef name. if want temporary querydef, use empty string name ...

'set qd = db.createquerydef set qd = db.createquerydef(vbnullstring) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -