Using Field.Locked on Sub-Form

S

shaggles

I've been having a lot of problems with using the [Field
Name].Locked property and I think I've narrowed it down to
the fact that the field I'm referencing is on a subform.
I'm trying to use the locked property to turn a field on
or off depending on the user but when the field is on a
sub-form I get a 'Object does not support this property or
method' error message. I've tried putting the code
directly in the sub-form's On Current event and
referencing the field liek this: Me!Field_Name.Locked
and I've tried puting it in the Main form and referencing
the field like this: Me!Subform.Forms!Field_Name.Locked
but I get the same error either way. Any suggestions?
 
M

Marshall Barton

shaggles said:
I've been having a lot of problems with using the [Field
Name].Locked property and I think I've narrowed it down to
the fact that the field I'm referencing is on a subform.
I'm trying to use the locked property to turn a field on
or off depending on the user but when the field is on a
sub-form I get a 'Object does not support this property or
method' error message. I've tried putting the code
directly in the sub-form's On Current event and
referencing the field liek this: Me!Field_Name.Locked
and I've tried puting it in the Main form and referencing
the field like this: Me!Subform.Forms!Field_Name.Locked
but I get the same error either way.


You should keep the distinction between fields in the form's
record source table/query and the controls on the form that
are used to interact with the fields clear in your mind and
messages. It would also be a good idea to post using your
actual names instead of a generic something like [Field
Name].

The Locked property only applies to a control so you would
get that message if the control had a different name than
the field. I.e. make sure you're this kind of reference:

Me.controlname.Locked = True


Your subform reference is using the wrong thing too, it
should be like this:

Me.subformcontrolname.FORM.controlname.Locked = True

Note the use of Form instead of Forms.
 
S

shaggles

Thanks. That did it.
-----Original Message-----
shaggles said:
I've been having a lot of problems with using the [Field
Name].Locked property and I think I've narrowed it down to
the fact that the field I'm referencing is on a subform.
I'm trying to use the locked property to turn a field on
or off depending on the user but when the field is on a
sub-form I get a 'Object does not support this property or
method' error message. I've tried putting the code
directly in the sub-form's On Current event and
referencing the field liek this: Me!Field_Name.Locked
and I've tried puting it in the Main form and referencing
the field like this: Me!Subform.Forms!Field_Name.Locked
but I get the same error either way.


You should keep the distinction between fields in the form's
record source table/query and the controls on the form that
are used to interact with the fields clear in your mind and
messages. It would also be a good idea to post using your
actual names instead of a generic something like [Field
Name].

The Locked property only applies to a control so you would
get that message if the control had a different name than
the field. I.e. make sure you're this kind of reference:

Me.controlname.Locked = True


Your subform reference is using the wrong thing too, it
should be like this:

Me.subformcontrolname.FORM.controlname.Locked = True

Note the use of Form instead of Forms.
 

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