Microsoft KB Archive/841916

From BetaArchive Wiki
Knowledge Base


Article ID: 841916

Article Last Modified on 7/28/2006



APPLIES TO

  • Microsoft Office Access 2003



This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

When you try to run a macro that uses the SetValue action to set the Visible property of one of the following objects, the macro may not run successfully:

  • A form
  • A check box control on a form or on a report
  • A Bound object frame control on a form or on a report that is used to display OLE objects and to work with OLE objects that are stored in tables

Additionally, you may receive the following error message:

You don't have the license required to use this ActiveX control.

You tried to open a form containing an OLE object or an ActiveX control or you tried to create an ActiveX control.

To obtain the appropriate license, contact the company that provides the licensed OLE object or ActiveX control.

This problem may occur when you turn on sandbox mode for Microsoft Office Access 2003 applications.

CAUSE

The Visible property of the objects that are mentioned in the "Symptoms" section is blocked when you turn on sandbox mode.

WORKAROUND

To work around this problem, you must create a function to set the Visible property of an object and then use a macro to run the function. To do this, follow these steps:

  1. Start Access 2003.
  2. Open your Access database (.mdb) or your Access project (.adp).
  3. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  4. On the Insert menu, click Module.
  5. Type or paste the following code in the Visual Basic Editor:

    Public Function SetVisible(frmTarget As Object, fValue As Boolean)
    
        frmTarget.Visible = fValue
    
    End Function
  6. On the File menu, click Save <Database Name>.
  7. In the Save As dialog box, type SetVisibleModule, and then click OK.
  8. Close the Visual Basic Editor.
  9. In the Database window, click Macros under the Objects section, and then click New.
  10. Create a new macro that is named SetVisibleMacro with the following action:

        Macro Name  :   SetVisibleMacro 
        ------------------------------------------
        Action      RunCode
    
    
        Action      :   RunCode 
        ------------------------------------------
        
        Function Name   SetVisible (<object reference>, <True or False>)

    Note You must replace the <object reference> placeholder with the Visual Basic reference to the object. This is the object that has the Visible property that you want to set.

    For example, if you want to set the Visible property for the Form1 form to False, you must set the Function Name action argument to the following:

    SetVisible (Forms!Form1, False)


STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. Turn on sandbox mode for Access 2003 applications. To do this, follow these steps:
    1. Start Access 2003.
    2. On the Tools menu, point to Macro, and then click Security.
    3. In the Security dialog box, click Medium on the Security Level tab, and then click OK.
    4. Close Access 2003.
  2. Start Access 2003.
  3. Open the Northwind.mdb sample database.
  4. In the Database window, click Forms under the Objects section.
  5. In the right pane, double-click Categories.
  6. In the Database window, click Macros under the Objects section, and then click New.
  7. Create a macro that is named TestVisibleMacro with the following action:

        Macro Name: TestVisibleMacro    
        ----------------------------------------
        Action      SetValue
    
    
        Action:     SetValue
        ----------------------------------------
        Item        Forms!Categories.Visible
        Expression  False
  8. Run the TestVisibleMacro macro.

    When you run the TestVisibleMacro macro, you may receive the error message that is mentioned in the "Symptoms" section.


REFERENCES

For additional information about the Microsoft Jet Expression Service sandbox mode, visit the following Microsoft Web site:

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

294698 How to configure Jet 4.0 to prevent unsafe functions from running in Access 2003



Additional query words: acc2003 macro security level

Keywords: kbcode kbcontrol kbmacro kbfunctions kbenable kberrmsg kbbug KB841916