Setting LOCKED in SETPROPERTY

N

Nancy

I want to lock a form or a field when a checkbox is equal to YES. Help shows
the following for the Enabled property.
SetProperty Control Name: txtDescription
Property: Enabled
Value: 0

Help also states:
Control Name Type the name of the field or control for which you want to set
the property value. Use only the control name, not the full syntax. Leave
this argument blank to set the property for the current form or report.

My field is named "Complete." Is that the Control Name? I tried the
following but it doesn't work. Any suggestions?
SetProperty Control Name: Complete (also tried leaving this blank)
Property: Locked
Value: -1
 
S

Steve Schapel

Nancy,

The name of the control (in this case the checkbox on the form) is by
default the same as the name of the field it is bound to, but this isn't
necessarily so. If you look at the Properties of the checkbox, you will
see the Name property.

What event are you assigning this macro to?

And what exactly do you mean by "doesn't work"? The macro runs but the
checkbox is still editable? You get an error message? Something else?
 
N

Nancy

Steve, my macro is on the "On Click" event.

The checkbox is named Complete so that is the name I use for the control
name in the macro. If I use that name with LOCKED and -1 for the value, the
macro does not fail but the LOCKED property does not change from "No" to
"YES" in the property sheet.

If I do not use a name in the "Control Name" field, the step fails with
error 2950.

I also added a SETPROPERTY to set the Enable property to 0 but that failed
with error 2950.

Is SETPROPERTY the correct way to prevent editing when Complete=Yes or is
there a better way?
 
S

Steve Schapel

Nancy,

If you are talking about the Click event of the Complete checkbox
itself, then no, that's not a good idea. Maybe it's After Update event,
or an event related to some other control, and/or the Current event of
the form.

And No, this will not alter what you see in the Property sheet. Changing
properties like this, using code or macros, can only ever result in a
tempoorary change, applicable during the life of the form, i.e. while it
is open. When the form is closed, the property reverts to that built
into its design via the property sheet setting. Understand?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top