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:
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:
- 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 <Database Name>.
- In the Save As dialog box, type SetVisibleModule, and then click OK.
- Close the Visual Basic Editor.
- In the Database window, click Macros under the Objects section, and then click New.
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
- Turn on sandbox mode for Access 2003 applications. To do this, follow these steps:
- Start Access 2003.
- On the Tools menu, point to Macro, and then click Security.
- In the Security dialog box, click Medium on the Security Level tab, and then click OK.
- Close Access 2003.
- Start Access 2003.
- Open the Northwind.mdb sample database.
- In the Database window, click Forms under the Objects section.
- In the right pane, double-click Categories.
- In the Database window, click Macros under the Objects section, and then click New.
Create a macro that is named TestVisibleMacro with the following action:
Macro Name: TestVisibleMacro ---------------------------------------- Action SetValue Action: SetValue ---------------------------------------- Item Forms!Categories.Visible Expression False
- 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