Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 907337 - Last Review: April 21, 2006 - Revision: 1.2
You receive an error message when you start Visual Basic for Applications code in an Access database
On This Page
SYMPTOMS
When you start Microsoft Visual Basic for Applications (VBA) code in
a Microsoft Access database, you may receive an error message that resembles the following:
The expression On Click you entered
as the event property setting produced the following error: A problem occurred
while Microsoft Access was communicating with the OLE Server or ActiveX
Control.
CAUSE
This issue may occur if the following conditions are true:
- You create an event handler, a function, or a subroutine to
start the VBA code in an Access form or report.
- You run the VBA code on a computer that uses different
non-Unicode language settings than the computer on which you created the event handler, the function, or the subroutine.
Note This issue may also occur if the VBA code contains accented characters or
special characters. Additionally, this issue may occur if an object name in the
Access database contains accented characters or special characters.
RESOLUTION
To resolve this issue, use the appropriate method.
Method 1: Verify the non-Unicode language
If you are running the VBA code on a Microsoft Windows XP-based computer or
on a Windows 2000-based computer, you may be able to resolve this issue by changing
the non-Unicode language setting on the
computer where you are running the VBA code. To verify and to change the non-Unicode language setting, follow these
steps.
Note Because there are several versions of Microsoft Windows, the
following steps may be different on your computer. If they are, see your
product documentation to complete these steps.
- Click Start, click Run,
type Intl.cpl, and then click
OK.
- Under Language for non-Unicode programs on the Advanced tab, verify that the language matches the language on the computer on which you created the event handler, the function, or the subroutine. If the language differs, click the
language that you want, and then click OK.
- Restart the computer.
Method 2: Remove accented characters or special characters from the VBA code and from database objects
To resolve this issue, remove any accented characters or special characters
that appear in the VBA code or in database objects. For example, form sections and report sections that
were created in localized versions of Access may contain accented characters or special
characters.
To rename an Access object, or a section in an Access object,
that contains accented characters or special characters, follow these steps:
- Start Access, and then open the database that you
want.
- Right-click the form or report that you want, and then
click Design view.
- Right-click the object that you want, and then click
Properties.
- On the All tab in the
Name box, type a name that does not contain accented characters or
special characters.
- After you rename the objects, open Visual Basic Editor to
determine whether your changes appear in the VBA code. The objects may retain the original names. If this behavior occurs, you must manually rename the objects in the VBA code.
Steps to reproduce the issue
- Start Access on a computer where the Russian versions of
Windows XP and Microsoft Office 2003 are installed.
- Create a new Access database.
- Add a form to
the database. By default, a form that is named Form1 is created.
- In Design view, add a command button to the
form.
- Right-click the command button that you added in step 4, and
then add the following code example to the Click event for the command button.
On Error GoTo Err_cmdMsgBox_Click
MsgBox "Hello World"
Exit_cmdMsgBox_Click:
Exit Sub
Err_cmdMsgBox_Click:
MsgBox Err.Description
Resume Exit_cmdMsgBox_Click
- Compile the Access database.
- Close the Visual Basic code window, and then close the
Access database.
- On a computer where the English versions of Windows XP and Office 2003 are installed, verify that the non-Unicode language is set to English (United States).
- Copy the Access database that you created in step 2 to the computer in step 8.
- Open the Access database, open the form that contains the
command button, and then click the command button to run the VBA code.
APPLIES TO
- Microsoft Office Access 2003
- Microsoft Access 2002 Standard Edition
- Microsoft Access 2000 Standard Edition
| kbtshoot kbbug kbprb KB907337 |
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
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please