Microsoft KB Archive/841916

= You may receive an error message when you run a macro that uses the SetValue action to set the Visible property of an object in Access 2003 =

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 &quot;Symptoms&quot; 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:  Start Access 2003. Open your Access database (.mdb) or your Access project (.adp). On the Tools menu, point to Macro, and then click Visual Basic Editor. On the Insert menu, click Module.  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  On the File menu, click '''Save  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) </li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

Steps to reproduce the problem
<ol> Turn on sandbox mode for Access 2003 applications. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Start Access 2003.</li> On the Tools menu, point to Macro, and then click Security.</li> In the Security dialog box, click Medium on the Security Level tab, and then click OK.</li> Close Access 2003.</li></ol> </li> Start Access 2003.</li> Open the Northwind.mdb sample database.</li> In the Database window, click Forms under the Objects section.</li> In the right pane, double-click Categories.</li> In the Database window, click Macros under the Objects section, and then click New.</li>  Create a macro that is named TestVisibleMacro with the following action:

<pre class="fixed_text">   Macro Name: TestVisibleMacro Action     SetValue

Action:    SetValue Item       Forms!Categories.Visible Expression False </li> Run the TestVisibleMacro macro.

When you run the TestVisibleMacro macro, you may receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">