vba - Trying as assign a SQL string to the record source property of Access report -
i have form pictured below. 3 sort buttons, 1 preview report button.
when sort buttons clicked, publicly declared variable called strsql updated.
i have code @ top of form
option compare database public strsql string option explicit
strsql updated , used populate list area.
one of buttons click events
private sub cmdreturndate_click() strsql = strsql1 & strsql2 & me!cbodistricts.value & weekendsort me!teacherslist.rowsource = strsql me!teacherslist.requery end sub
i trying use strsql recordsource report being called on preview report button.
i have line of code in event open function report , can see correct sql in variable strsql
private sub btnpreviewreport_click() msgbox (strsql) rem assign sql string reports data property. docmd.openreport "reportname", acviewpreview end sub
i either need pass sql report or reference variable in reports recordsource property.
attempt reference in report open event
private sub report_open(cancel integer) me.recordsource strsql end sub
the report not showing data, not recognizing variable - no output.
question is: how can access/assign strsql reports recordsource property?
me.recordsource strsql
should me.recordsource = strsql
but know there wherecondition
option when open report ?
can use openargs
pass parameter report/form when open it.
docmd.openreport reportname:="somereport", _ wherecondition:="category = 33", _ openargs:="furniture"
Comments
Post a Comment