Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't set locked / enabled ? 1

Status
Not open for further replies.

DahMurf

Programmer
Apr 12, 2003
44
US
In a form's onOpen I was setting several fields to enabled = false. I could set most of the fields but a few of them couldn't be set. When typing them in, the autoformat drop down would only show "value" where the others would allow many controls like locked & enabled.
When I try to run it gives me the error
438
Object doesn't support this property or method.

I can set the value on the properties when editing the form but I want to turn this on & off on the fly.

Any ideas what to check? I can't find anything in the field definition that's wrong.
Thanks
 
What type of controls are they?

Also, verify that you don't have a label with the same name. Something that frustrated the heck out of me for a bit, was that I had two controls with the same name and it was causing issues.
 
jpstroud,
Thank you for your response. I had inconsistancies between the name & control source on the text boxes as seen in the properties. I was using the control source name as the control name where I should have been using the name. I made them consistant and it works!

Now my next problem is I'm trying to set the control on a subform and I can't seem to get that text correct to make them enable = false.

Could anyone give me an expample of the proper text to set a subform's text box control to enable = false?

Thanks!
 
If you're looking for VBA code, it's (switch object with the name of your control or object):

Code:
object.enabled = false
 
Thanks!

I gave up!

I did find how to reference a subform in the following manor:

Code:
Forms!MainFormName!SubFormName.SetFocus

I never could get the control to set enabled = false on the subform. I tried:

Code:
Forms!MainFormName!SubFormName.Control.Enabled = False

At any rate. I gave up & went a different route. I wouldn't mind the answer for future reference but it's no longer standing in the way of progress.

Thanks so very much for your assistance.
 
Remove the MainFormName from there. Use Forms!SubFormName!Control.Enabled = False.
 
That didn't work for me. I have the main form active and am trying to make a field on the subform to be not enabled. This code is in an onMouseClick area of the main form.

I get the message:

Microsoft Access can't find the form 'SubFormName' referred to in macro expression or Visual Basic code.

I know I have the correct subform name since I can set focus to the subform I just can't set the enable to false. Almost like I can access the sub form but not the text box.

Any ideas?

Thanks so much for your assistance.





 
I just tried the following on a form (to disable a subform control) and it worked fine:

[subformname]![control].Enabled = False

Make sure that you have a way to renable the control, and leave the brackets on if there are spaces in the names.
 
The subform name probably won't be what you expect. Open your form in design view, select the subform object, right click to open the property box, and select the Other tab. The name of the subform will be displayed on the first line.

You, of course, can change the name if you wish to.

If the main form is named MyMainForm, the subform is named MySubForm, and the control is named MyComboBox... refer to the control this way...

Forms!MyMainForm!MySubForm!MyComboBox.Enabled = False

Check this FAQ for more information...
faq702-2206

Randy
 
This is the code you supplied:

Code:
[subformname]![control].Enabled = False

When used exactly as typed, leaving in the brackets & only changing to my names, it worked!!!
Thank you!!!

I think my problem was a combination of the incorrect use of . and/or ! and using Forms!. Also I used the brackets [ ] around my control. It is only one word but may have been what helped.

Thank you!
 
Glad to hear it. Looking back, I even switched a ! with a . on accident. That's probably why the earlier one didn't work.

And remember, any time you have a control with a space, use the brackets (I design without the spaces at all, so sometimes I don't think about them).
 
I try to design without spaces also but my subform name ended up with spaces when generated through the wizard.

Thanks for sticking with me till we got resolution. I gave you a star for your efforts & help! I wouldn't have figured it out on my own!

Thanks a bunch!! :D
 
This issue about SPACE characters is covered in this FAQ

To help you remember when to use ! and when to use . :-

! Goes BEFORE anything you have given a name to.
. Goes BEFORE anything Microsoft has defined the name of.

The exception to this is in writing SQL strings where you use . throughout
EG.
SELECT tbl1.field1, tbl2.field2
FROM tbl1 INNER JOIN tbl2
ON tbl1.PK1 = tbl2.FK1



'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top