executing a statement 
Author Message
 executing a statement

Hello everyone,

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 = true      -
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.  Thanks.

David



Fri, 15 Jul 2005 03:41:45 GMT  
 executing a statement

Quote:

>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 = true      -
>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.

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
        . . .

--
Marsh
MVP [MS Access]



Fri, 15 Jul 2005 04:40:27 GMT  
 executing a statement
Thanks Marshall, I'll use it.
David

Quote:

> >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.

> 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
> . . .

> --
> Marsh
> MVP [MS Access]



Fri, 15 Jul 2005 05:45:14 GMT  
 executing a statement

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]



Fri, 15 Jul 2005 10:53:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Very simple - How to execute sub statements before the end statement

2. errors different when executing SQL statements via recordset or connection object

3. how to execute SQL statements

4. Problems Executing SQL Statements

5. Execute SQL Statement???

6. Progress of an executing SELECT statement?

7. executing SELECT statement with return value from other stored procedure

8. When I use connection object (ADO) to execute this statement

9. Execute SQL Statement???

10. How to execute a statement into a variable string

11. Execute SQL statements in a MySQL database through ADODB.Connectio

12. Cannot execute select statement

 

 
Powered by phpBB® Forum Software