I also want to know if it's possible to set a variable to equal a control
source based on a variable?
dim x
x=Me. & var1 & .ControlSource.Text
Can this be done without actually typing the txtboxes name as to using a
variable in its place? Thanks.
Kou
Dirk Goldgar - 31 Jul 2007 22:28 GMT
> I also want to know if it's possible to set a variable to equal a
> control source based on a variable?
[quoted text clipped - 5 lines]
> Can this be done without actually typing the txtboxes name as to
> using a variable in its place? Thanks.
Use:
x = Me.Controls(var1).ControlSource
There is no ".Text" property of the ControlSource, which is itself a
text property.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
> I have several txtBoxes that I want to edit the Control Sources of
> each of them. If I set a variable to the name of the txtBox, can I
[quoted text clipped - 12 lines]
>
> Is this possible? Still Confused? (So am I sometimes...)
You can use the name of the control as a string index into the Controls
collection; like this:
Me.Controls(Array(I)).Controlsource = "=" & SomeFormula

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Kou Vang - 31 Jul 2007 22:52 GMT
I forgot to mention that I am trying to edit txtBoxes that are in a report
through a form I am running. Can I open a report while running the code from
the form, and edit the txtboxes of the report through the forms code?
Kou
> > I have several txtBoxes that I want to edit the Control Sources of
> > each of them. If I set a variable to the name of the txtBox, can I
[quoted text clipped - 17 lines]
>
> Me.Controls(Array(I)).Controlsource = "=" & SomeFormula
Dirk Goldgar - 31 Jul 2007 23:10 GMT
> I forgot to mention that I am trying to edit txtBoxes that are in a
> report through a form I am running. Can I open a report while
> running the code from the form, and edit the txtboxes of the report
> through the forms code?
I think you'd better put the code to modify controlsources in the Open
event of the report. Even if Access will let you do it after the
report's Open event has finished -- and it may not -- I'm not sure if
there's any other way for you to ensure that the text boxes'
controlsources are set before the report actually starts to print them.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)