Calling a New Event Procedure

  • Thread starter Thread starter tobesurveyor via AccessMonster.com
  • Start date Start date
T

tobesurveyor via AccessMonster.com

Good day,

I am trying to populate a control with a new On_Click Event when the form
opens. The idea is when the form loads and based upon the role, determines
what control is present. When a user with a role 1 opens the form, I want
an image to load and the Mouse Move Event to be the sub MouseMe. When the
role is 0 then the image does not load and the Mouse Mouse Event is Null.

I can make the Mouse Move Event with the following: Me.lblLaunch01.
OnMouseMove = ""

I have tried doing the following: Me.lblLaunch01.OnMouseMove =
"EventProcedure" and also Me.lblLaunch01.OnMouseMove = "MouseMe", but it is
trying to load a macro, and my sub is in VBA.

What would be the proper coding to reference the MouseMove event with the sub
MouseMe?

Thanks for the help in advance,
Chris
 
tobesurveyor said:
Good day,

I am trying to populate a control with a new On_Click Event when the form
opens. The idea is when the form loads and based upon the role, determines
what control is present. When a user with a role 1 opens the form, I want
an image to load and the Mouse Move Event to be the sub MouseMe. When the
role is 0 then the image does not load and the Mouse Mouse Event is Null.

I can make the Mouse Move Event with the following: Me.lblLaunch01.
OnMouseMove = ""

I have tried doing the following: Me.lblLaunch01.OnMouseMove =
"EventProcedure" and also Me.lblLaunch01.OnMouseMove = "MouseMe", but it is
trying to load a macro, and my sub is in VBA.

What would be the proper coding to reference the MouseMove event with the sub
MouseMe?


Me.lblLaunch01.OnMouseMove = "[Event Procedure]"
 
tobesurveyor via AccessMonster.com said:
Good day,

I am trying to populate a control with a new On_Click Event when the
form opens. The idea is when the form loads and based upon the role,
determines what control is present. When a user with a role 1 opens
the form, I want an image to load and the Mouse Move Event to be the
sub MouseMe. When the role is 0 then the image does not load and
the Mouse Mouse Event is Null.

I can make the Mouse Move Event with the following: Me.lblLaunch01.
OnMouseMove = ""

I have tried doing the following: Me.lblLaunch01.OnMouseMove =
"EventProcedure" and also Me.lblLaunch01.OnMouseMove = "MouseMe", but
it is trying to load a macro, and my sub is in VBA.

What would be the proper coding to reference the MouseMove event with
the sub MouseMe?

Thanks for the help in advance,
Chris

If you make MouseMe a Function instead of a Sub, you could do this, I
think:

Me.lblLaunch01.OnMouseMove = "=MouseMe()"

Otherwise you'd have to have defined an event procedure for the
control's MouseMove event:

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

Call MouseMe

End Sub

And then, you'd dynamically set the control's OnMouseMove property to
"[Event Procedure]", so that it would know to call the sub when the
event is raised.

But wouldn't it be easier just to check the user's role in the control's
MouseMove event, and either call MouseMe or not, rather than dynamically
changing the OnMouseMove property?
 
Back
Top