Set Statement

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
 
R

RoyVidar

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)
 
B

Banana

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)
 
S

Stuart McCall

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")
 
J

Jack Leach

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top