Cannot explicitly refer to controls on a report (MS Access/VBA) -


how refer report's controls explicitly? referring implicitly works expected:

me.lbltest.visible = true 

however, of attempts @ referencing control explicitly meet various nonsensical runtime errors. access' favorite:

"the report name 'rpttest' entered misspelled (it's not) or refers report isn't open (it is) or doesn't exist (it does)."

i've tried dozen syntax variations msdn , everywhere else find, producing errors:

reports!rpttest.lbltest.visible = true     ' ^--expected syntax, forms!frmname.ctlname.property reports!("rpttest").lbltest.visible = true reports![rpttest].lbltest.visible = true reports("rpttest").controls("lbltest").visible = true etc. etc. 

this should no different referring forms' controls, right? there must way refer explicitly report's controls.

check names of reports access thinks open.

with report open, go immediate window. ctrl+g take there.

paste in for each rpt in reports : ? rpt.name : next 1 line , press enter. access tell names of open reports sees them.

here immediate window example system 1 report, rptfoo, open ...

for each rpt in reports : ? rpt.name : next rptfoo 

the problem you're facing rpttest open, access disagrees. discrepancy can caused @ least 3 ways:

  1. rpttest see when report open, report's caption property instead of name
  2. rpttest subreport contained in other open report. reports collection, access looks find open reports, contains "top-level" reports open. if you're dealing subreport, reference via parent report ... reports!rptparent!subreportcontrol!lbltest.visible subreportcontrol name of subreport control contains rpttest. careful because name of subreport control may not rpttest --- need name of subreport control, not name of report contains.
  3. if rpttest contained in subform/subreport control within form (instead of within report), situation similar #2, must reference via parent form ... forms!yourformname!subcontrolname!lbltest.visible

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -