Shelli,
i'm not sure that what you're asking for is possible in this way. the
Control Source property of a text box is expecting a string if you
want to access an object. if you pass in a function, it assumes that
you want to see the results of that calculation, just as you would on
a report where you say "sum([fieldname])"
actually, i'm not sure why you would want to do this in this fasion
for a couple of reasons. First, having fields named as numbers will
eventually make it confusing to remember what in which fields (and i
pity the fool who tries to take over a db created like that!).
Second, this is exactly the sort of thing VBA was created for, and
it's so easy to do simple tasks like this that you would definately
benefit more from learning the VBA that can accomplish many tasks than
figuring out how to do this one limited task.
anyway, to do this with VBA, you would simply use the OnLoad event (or
the Current event, if it needs to be re-evaluated with each record
change) and set the control source property. you can get to either
event by clicking the build (...) button next to the event in the
property window for the form. it will look something like this:
sub form1_OnLoad()
dim ctl as control
dim strControlSource as string
' set the contol variable to the control you want to work with
set ctl = me.[ControlName]
' here you would put the calculation that evaluates to the name
of the
' control source you want to use. i would not recommend
numbers.
' concatenated strings are very nice, though, like "Field" & i
where i
' = 1 will return "Field1" - still not a very useful name, but
you get
' the point.
strControlSource = [Calculation that evaluates to the control
source]
' put the string you just put together into the control source
property
ctl.controlsource = strControlSource
' you can do this for as many controls as you wish, just change
the
' ctl variable to a new control.
hope that helps. tom
star_sphere (AT) yahoo (DOT) com (Shelli Carol) wrote in message news:<736cb06d.0309012302.5ef1f6d9 (AT) posting (DOT) google.com>...
Quote:
Good day,
I have:
1) A table with numbered fields (1, 2, 3, etc.)
2) A form text box, whose ControlSource property contains an
expression. This expression returns a number.
If I just put a number in the ControlSource property, the text box
would display the appropriate contents of the field in my table.
However, because I have an expression returning a number, the text box
displays the number. How can I get the ControlSource property to
recognize the number as a field name and get the appropriate value for
me?
Thank you!
Shelli Carol
Scottsdale, Arizona |