ACC97: Error When You Click a Custom Command Bar ButtonID: Q193167
|
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.
This problem happens when the database has a long file name, and you assign a function using the following syntax:
.OnAction = "=<function name>()"
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>"
Microsoft has confirmed this to be a problem in Microsoft Access 97.
Option Explicit
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
TestA new menu bar should appear.
Additional query words: pra
Keywords : kberrmsg kbdta MdlGnrl
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: May 13, 1999