I have searched everywhere for this, and it seems like a simple fix, but I can't seem to find the solution. I have several Rectangle controls in my Access 2013 form, and I'm creating an OnClick event that handles them all. I've worked on a few different methods, and I think I found the simplest/cleanest way to do it. I put the controls in a collection and change the OnClick event for each control. Here's my problem: Access opens the form and recognizes that I changed the event for the control, but once I click the control, it throws an error and will not execute the event.
The Error:
"The expression On Click entered as the event property setting produced the following error: The expression you entered has a function name that Microsoft Access can't find."
The Code:
Private Sub Form_Load()
Dim m_colRectangle As Collection
Dim ctl As Access.CONTROL
Set m_colRectangle = New Collection
For Each ctl In Me.Controls
If ctl.ControlType = acRectangle Then
If ctl.Name = "shpTest" Then
m_colRectangle.Add ctl, ctl.Name
ctl.OnClick = "=TestClick()" ' <--- Error on this line
End If
End If
Next ctl
End Sub
Private Sub TestClick()
MsgBox "Test"
End Sub
Alternatively, I tried a simple shpTest.OnClick = "=TestClick()"
in the Form_Load event, and this produced the same error. Anyone have any ideas?