Function of Event Property causing problem

  • Thread starter Thread starter Mark A. Sam
  • Start date Start date
M

Mark A. Sam

Hello,

I too the following Event Procedure from the MouseMove Property of selected
controls:

Private Sub Box241_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)

If [SelectAreas] <> 2 Then
[SelectAreas] = 2
Call SelectAreas_AfterUpdate
End If

End Sub


And created a Public Procedure in side of the form module:
Public Sub MouseMove2()

If [SelectAreas] <> 2 Then
[SelectAreas] = 2
Call SelectAreas_AfterUpdate
End If

End Sub

Assigning the Function to the control's MouseMove property:

=MouseMove2()

I get the following Message:

The expression On Mouse Move you entered as the event property setting
produced the following error: The expression you entered contains invalid
syntax:
*Expression may not result in the name of a macro, the name of a
user-defined function, or {Event Procedure].
*There may have been an error evaluating the function, event, or macro.

The Function the the call to the Event Procedure work fine and generates an
err =0 with no err.description. If I put a break on the End Sub statement,
I get no problems until I step out of that. On the screen, things work
exactly as they should. I see no reason for the err and need to get rid of
it. Thanks for any help.

God Bless,

Mark A. Sam
 
Public Sub MouseMove2()
End Sub

Assigning the Function to the control's MouseMove property:

=MouseMove2()

A sub is not a function. Change 'Public Sub' to 'Public Function' and 'End
Sub' to 'End Function'. (Actually, you won't have to do the latter. VBA is
smart enough to do that automatically when you change the first line).

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top