vba - Is there a more efficient way to display multiple query results in different text boxes on a Form -
i have form several different text boxes. each text box populated result of different query. i'm not familiar vba / access (i teaching myself) , not sure if i'm doing efficient. hoping suggest maybe less cumbersome way of populating text boxes on form different queries, or perhaps suggest better variable naming convention.
*edit - think there way place formula directly in text box rather doing through vba received #name error.
private sub form_load() dim db dao.database dim qdf querydef dim rst recordset dim qdf2 querydef dim rst2 recordset set db = currentdb() set qdf = db.querydefs("qrygettotaltransactions") set rst = qdf.openrecordset set qdf2 = db.querydefs("qrygettotaltransactionsinmanagement") set rst2 = qdf2.openrecordset [form_portfolio status].totaltransaction_txt.value = rst![total] [form_portfolio status].totalinmanagement_txt.value = rst2![total] end sub
in each of 2 examples, you're retrieving single value saved query. dlookup values less code.
dlookup("[total]", "qrygettotaltransactions") dlookup("[total]", "qrygettotaltransactionsinmanagement")
you assign dlookup
return value text box's .value
property ... doing recordset value. or use dlookup
expression text box control source.
regarding efficiency, dlookup
performance not faster recordset approach. wouldn't need code manage dao objects. perhaps there savings in developer time, should count something. :-)
Comments
Post a Comment