Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    300

    Question Unanswered: Error on Mainform_Lock

    I have the following code in a form so that the user can just view the information without accidentally changing the information. Unfortunately, it will not let me Lock ALL the fields, so I have to comment some out.

    I am getting a Run-Time error 438 =Object does not support this property or method..

    What can I do to lock this field?

    Sub Mainform_Lock(OnOff As Boolean)

    Me![Customer_ID].Locked = OnOff
    ' Me![Invoice_ID].Locked = OnOff

    End Sub

  2. #2
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Your code looks fine. The error message is saying that the class to which Invoice_ID belongs does not have a property or method called Locked. Yet presumably this is a text box, maybe a combo box or list box, all of which can be locked. I have simulated your code and it works fine. By the way you cannot change these sort of properties while the control has the focus but that situation gives an entirely different error message.

    Here are some things to try.

    1. Are you absolutely sure that it is these statements that are triggering the error message? Have you tried stepping through the code via F8?

    2. I have occasionally got unprintable characters in my VBA statements that precipitate all sorts of strange behaviour and messages. (At least that's what I think is happening.) Try deleting the lines entirely and rewriting them.

    3. When you do rewrite the statements, first go to Tools/Options on the VBA menu bar. Make sure Auto List Members is checked. Then I recommend you use a period after Me rather than an exclamation mark. After you type the period a list of all members of Me will be shown. Scroll down to Invoice_ID and press [Tab]. Then type another period. This time a list of all properties and methods will be shown. Scroll down, select Locked and press [Tab]. This practice makes sure all components are recognised by VBA.

    4. Finally check the included object libraries. You should have an Access Object Library included in the list shown under Tools/References on the VBA menu bar. You should also avoid including any other libraries that might duplicate object names. To check this and assuming your control is a textbox, go to the Object Browser. Make sure <All Libraries> is selected. Type "TextBox" (without the quotes) in the search field and click on the search button. See how many hits you get. You should only see one class called textbox in the Access library. If there is another library with a class called TextBox then it is possible that Access is checking this class for the property. (However this one is whistling in the wind as if it works for some controls then it should work for all.)

    Question: Any reason you are using the Locked property rather than the Enabled property. The latter has the advantages of giving the user a visible sign that the field is disabled and of not being able to take the focus.

    (My guess, and I'm prepared to put 50 Centavos on it, is that the message is being caused by something else.)
    Last edited by Rod; 07-18-04 at 17:30.
    Rod

    fe_rod@hotmail.com

  3. #3
    Join Date
    Nov 2003
    Posts
    300

    Talking

    Thanks very much! I will give it a try and see what I come up with.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •