Click to See Complete Forum and Search --> : Using Variables within DAO References


Bill Betts
October 22nd, 1998, 04:20 PM
In Access97 VBA you refer to a DAO in the following format Report!ReportName.ObjectName.Property


What I'm trying to do is use a variable inside this reference. I have a form in which users can change a specific property of an OLE Object (namely chart type) of various reports. Right now i'm using a simple case statement with all the report names but whenever I add a new report I have to make sure and add it to the case statement.


Any help is greatly appreciated


thanks

richardj
May 30th, 2001, 04:13 AM
Hi
I'm unsure which bit you want to replace with a variable, but I hope this helps:
Use brackets, instead of an exclamation (!).
To use a string variable instead of a report name:
Reports(...string variable...).ReportProperty or
Reports(...string variable).Control.ControlProperty
- there are other ways as well, eg if you can be certain there's only one report open you could use the index number, ie Reports(0).ReportProperty etc.

You can refer to almost anything in this way, eg
Reports(strReportName).Controls(strControlName).Text = "Hello"