G
Guest
I am trying to write code that would take several controls on a form and move
them 1.75 inches to the right. I have never used collections in my code
before, so I am not sure what I am doing wrong. A, B, C, etc. are names of
controls on my form. My code gives me this run-time error:
Run-time error '2100':
The control or subform control is too large for this location.
The code halts on this line:
element.Left = element.Left + 1.75 * 1440.
It appears element is equal to the value of the control and not the name of
the control. If I put "A" through "M" in quotes, I get a different runtime
error on the "For each" line:
Run-time error '424':
Object Required
At that point, element=nothing.
Here is my code:
Dim element
Dim colElements As Collection
colElements.Add A
colElements.Add B
colElements.Add C
colElements.Add D
colElements.Add E
colElements.Add F
colElements.Add G
colElements.Add H
colElements.Add I
colElements.Add J
colElements.Add K
colElements.Add L
colElements.Add M
For Each element In colElements
element.Left = element.Left + 1.75 * 1440
Next element
I realize that I could simply avoid using for...each...next routines, but I
am actually running multiple actions on about 100 fields to move controls
around a form based on certain situations.
--
Brian Scheele
IT Manager
Clark Filter
3649 Hempland Road
Lancaster, PA 17601-1323
them 1.75 inches to the right. I have never used collections in my code
before, so I am not sure what I am doing wrong. A, B, C, etc. are names of
controls on my form. My code gives me this run-time error:
Run-time error '2100':
The control or subform control is too large for this location.
The code halts on this line:
element.Left = element.Left + 1.75 * 1440.
It appears element is equal to the value of the control and not the name of
the control. If I put "A" through "M" in quotes, I get a different runtime
error on the "For each" line:
Run-time error '424':
Object Required
At that point, element=nothing.
Here is my code:
Dim element
Dim colElements As Collection
colElements.Add A
colElements.Add B
colElements.Add C
colElements.Add D
colElements.Add E
colElements.Add F
colElements.Add G
colElements.Add H
colElements.Add I
colElements.Add J
colElements.Add K
colElements.Add L
colElements.Add M
For Each element In colElements
element.Left = element.Left + 1.75 * 1440
Next element
I realize that I could simply avoid using for...each...next routines, but I
am actually running multiple actions on about 100 fields to move controls
around a form based on certain situations.
--
Brian Scheele
IT Manager
Clark Filter
3649 Hempland Road
Lancaster, PA 17601-1323