Question : Error 438 Obejct doesn't support property or method

I have a front end database that is being distributed to several users.  The front end works perfect on my laptop, and another desktop I tested it on.  

However when I placed the database on a second deskstop to test the following code gives me an error.

Note the code works perfect on the two previous pcs I tested it on so I am guessing the problem has to do with a setting.  can anyone help.

See code below.

Private Sub lockfields()
    For Each ctl In Forms!frmPurchaseOrderMain
        On Error Resume Next
        Err = 0
        Me(ctl.Name).Locked = True   <-------------------  Error Occurs Here
        On Error Resume Next
        Err = 0
    Next ctl
    Forms!frmPurchaseOrderMain.Refresh
    Forms!frmPurchaseOrderMain.Requery
End Sub

Answer : Error 438 Obejct doesn't support property or method

lashler2,

  "I am still curious as to why the error will show up on one computer but not the other two?"
Well you have some non-standard error handling in your code.

As Natchiket has mentioned, my guess is that you are using this error handling scheme to bypass controls that are not of the type you want.

If you still get errors because you want only certain contols of a certain type locked, you can use the "Tag" property of thoes controls to weed out only the controls you need:
For Each ctl In Forms!frmPurchaseOrderMain
    If TypeOf ctl Is TextBox Then
        If ctl.tag="x" then
            Me(ctl.Name).Locked = True   <-------------------  Error Occurs Here
        end if
    End IF
Next ctl

This will only lock "Textboxes" that have their "Tag" property set to "x".

You may also wish to check the way the individual machiens are setup to handle errors:
Tools-->Options-->General-->Error trapping.
From the VBA Help files:

Error Trapping

Determines how errors are handled in the Visual Basic development environment. Setting this option affects all instances of Visual Basic started after you change the setting.

Break on All Errors  Any error causes the project to enter break mode, whether or not an error handler is active and whether or not the code is in a class module.

Break in Class Module  Any unhandled error produced in a class module causes the project to enter break mode at the line of code in the class module which produced the error.

Break on Unhandled Errors  If an error handler is active, the error is trapped without entering break mode. If there is no active error handler, the error causes the project to enter break mode. An unhandled error in a class module, however, causes the project to enter break mode on the line of code that invoked the offending procedure of the class.



JeffCoachman
Random Solutions  
 
programming4us programming4us