Set Statement

  • Thread starter Thread starter Howard Glassman
  • Start date Start date
H

Howard Glassman

How do I use the SET statement to refer to a programatically selected object.

dim r as report
dim c as control

set r = reports!myreport

mycontrol = "control_1"

set c = r.mycontrol

I get the error that mycontrol is not an object
 
Howard said:
How do I use the SET statement to refer to a programatically selected
object.

dim r as report
dim c as control

set r = reports!myreport

mycontrol = "control_1"

set c = r.mycontrol

I get the error that mycontrol is not an object

if "control_1" is the name of the control in question, try:

set c = r.controls(mycontrol)
 
Is mycontrol supposed to be a string referencing a control name?

If so, then the only way to use this in that manner is to explicitly
reference the collection containing that control.

Set c = r.Controls(mycontrol)
 
Howard Glassman said:
How do I use the SET statement to refer to a programatically selected
object.

dim r as report
dim c as control

set r = reports!myreport

mycontrol = "control_1"

set c = r.mycontrol

I get the error that mycontrol is not an object

If you have the name of a control in a variable, the syntax you need to use
is:

Set c = r(mycontrol)

or to set it literally, without the variable:

Set c = r("control_1")
 
or, if you don't need the control in a variable (probably not likely but)....
do it as you are trying without the variable:

Set r = Reports!myreport
Set c = r.control_1

Otherwise for a string of the control name you will need the method
suggested by the others.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Back
Top