vba - Access: Setting a source object to another source object path -


i'm trying crazy again. use line of code:

reports![prntrep].sourceobject = forms![search form]!subform1.sourceobject 

the source object of subform1 dynamically depending on query need search. want source of report set same query, don't need make bunch of different reports. throws error 2465, application defined or object defined error.

a report not have sourceobject property. reason access throws error #2465, "application-defined or object-defined error" when attempt reference it.

here immediate window example system:

' first demonstrate report accessible ... debug.print reports!rptfoo.name rptfoo  ' when referencing sourceobject ... debug.print reports!rptfoo.sourceobject ' <-- error 2465 

perhaps want alter report's recordsource instead:

' current recordsource ... debug.print reports!rptfoo.recordsource select rmy.id, rmy.reportdate, rmy.gainorloss record_matyields rmy; ' change recordsource saved query ... reports!rptfoo.recordsource = "qrybar" ' confirm recordsource altered ... debug.print reports!rptfoo.recordsource qrybar 

the report displayed 6 rows original recordsource. saved query includes where condition limits results 2 of rows. altering recordsource above caused report display 2 rows without forcing report design mode, unlike macro approach mentioned in comment.

unfortunately don't know enough macros fix yours. avoid macros.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -