Quote:
>Thanks Marshall, I'll use it.
>> >I am trying to set the visible property of a form from an entry in a
>table.
>> >I have the value - Forms![formname]![subform].form.visible =
> -
>> >in a table text field. How do I get it to execute once it is retrieved
>from
>> >the sql statement into a variable? Is that the best way to do this?
>This
>> >process does need to be table driven, however because the "visible"
>> >property is going to change all the time.
>"Marshall Barton" wrote
>> You can not execute uncompiled statements, regardless of
>> where they come from.
>> The usual way to perform actions based on data in a table is
>> to place an action code number and a few prameters in the
>> table. For example, a 1 in the Action field could mean set
>> a subform invisible, the Param1 field would contain the name
>> of the form and field Param2 the name of the subform
>> control. Then when you want to perform the action, you
>> would call a Sub procedure something along the lines of this
>> air code:
>> Public Sub PerformAction(lngCode As Long, _
>> strParam1 As String, _
>> strParam2 As String)
>> Select Case lngCode
>> Case 1
>> Forms(strParam1)(strParam2).Visible = False
>> Case 2
>> . . .
Another way to do this kind of thing is to put function
calls in the field and use the Eval function to execute the
function. The trouble with this approach is that the
expression service that handles the evaluation of the
function's arguments can only deal with constants, user
defined public functions, built-in functions and the
**Value** of fully qualified control references. Your
simple case of making a subform control invisible could be
done with something like this:
Field: SetVisibility("formname", "subform", False)
Public Function SetVisibility(strParam1 As String, _
strParam2 As String, _
bolOnOff As Boolean)
Forms(strParam1)(strParam2).Visible = bolOnOff
End Function
and when you want to call the function, the code would be:
dummy = Eval(thefield)
I do prefer the first approach, but thought you should be
aware of this other way just in case your circumstances call
for it.
The Run method can also be used in a somewhat similar
manner.
--
Marsh
MVP [MS Access]