Solved

Error 438 Obejct doesn't support property or method

Posted on 2008-10-30
6
322 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:lashler2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22841131
Private Sub lockfields()
    For Each ctl In Forms!frmPurchaseOrderMain
        On Error Resume Next
        Err = 0
        Forms("frmPurchaseOrderMain")(ctl.Name).Locked = True
        On Error Resume Next
        Err = 0
    Next ctl
    Forms!frmPurchaseOrderMain.Refresh
    Forms!frmPurchaseOrderMain.Requery
End Sub
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 100 total points
ID: 22841187


Private Sub lockfields()

dim ctl as control

    For Each ctl In Forms!frmPurchaseOrderMain
        On Error Resume Next
        Err = 0
        Forms("frmPurchaseOrderMain")(ctl.Name).Locked = True
        On Error Resume Next
        Err = 0
    Next ctl
    Forms!frmPurchaseOrderMain.Refresh
    Forms!frmPurchaseOrderMain.Requery
End Sub
0
 
LVL 17

Assisted Solution

by:Natchiket
Natchiket earned 100 total points
ID: 22841196
Not sure about the setting you want to change but if there are labels etc on the form attempting to lock them won't work

Something like this might be more appropriate
For Each ctl In Forms!frmPurchaseOrderMain
    If TypeOf ctl Is TextBox Then
        Me(ctl.Name).Locked = True   <-------------------  Error Occurs Here
    End IF
Next ctl
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lashler2
ID: 22842347
Thanks for the comments I will check to see if any of the suggestions fixed the problem when I go back to the computer giving the error in about two hours.  

I am still curious as to why the error will show up on one computer but not the other two?

Any suggestions?
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 300 total points
ID: 22847801
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
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22907651
;-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question