ACC97: Error When You Click a Custom Command Bar Button
ID: Q193167
|
The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.
When you click a menu or button on a command bar, you may see the following
error message:
The expression you entered has a field, control or property name
that Microsoft Access can't find.
CAUSE
This problem happens when the database has a long file name, and you assign
a function using the following syntax:
.OnAction = "=<function name>()"
RESOLUTION
Do not include an equal sign (=) and parentheses (()) when you assign the
function to the OnAction property of the command bar. For example, assign
the OnAction property using the following syntax:
.OnAction = "<function name>"
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 97.
MORE INFORMATION
Steps to Reproduce Problem
- Create a new database named Db1.mdb.
- Insert a new module, and then create a reference to
Microsoft Office 8.0 Object Library.
- Type the following line in the Declarations section if it is not
already there:
Option Explicit
- Type the following procedures:
Sub Test()
Dim MBar As CommandBar
Dim MBarItem As CommandBarControl
Set MBar = CommandBars.Add(Name:="Test Bar")
MBar.Visible = True
Set MBarItem = MBar.Controls.Add(Type:=msoControlButton)
With MBarItem
.Caption = "Test"
.Style = msoButtonCaption
.OnAction = "=RunMe()"
End With
End Sub
Function RunMe()
MsgBox "You pressed a toolbar button!"
End Function
- On the File menu, click Save. Type Module1
in the Save As dialog box, and then click OK.
- To test this function, type the following line in the Debug window,
and then press ENTER:
Test
A new menu bar should appear.
- On the Test menu bar, click Test. You should get a message box
that reads "You pressed a toolbar button!" Click OK.
- On the File menu, click Exit.
- Open Windows Explorer and change the name of the file to
This is a long file name.mdb.
- Open the "This is a long file name.mdb" file.
- On the Test menu bar, click Test. You should receive the error message
mentioned in the "Symptoms" section.
Additional query words:
pra
Keywords : kberrmsg kbdta MdlGnrl
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug