Microsoft Knowledge Base Email Alertz

(841916) - Explains that setting the Visible property of a form object, a check box object, or a bound object frame object by using the SetValue action in a macro may cause an error. Instead, use the macro to run a function that sets the Visible property.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 841916 - Last Review: July 28, 2006 - Revision: 3.3

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

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

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

On This Page

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:
http://office.microsoft.com/assistance/preview.aspx?AssetID=HP010446591033 (http://office.microsoft.com/assistance/preview.aspx?AssetID=HP010446591033)
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
294698  (http://kbalertz.com/Feedback.aspx?kbNumber=294698/ ) How to configure Jet 4.0 to prevent unsafe functions from running in Access 2003

APPLIES TO
  • Microsoft Office Access 2003
Keywords: 
kbcode kbcontrol kbmacro kbfunctions kbenable kberrmsg kbbug KB841916
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate