Retrieving Control Name

M

Mark A. Sam

Hello,

Does anyone know a way of retriving the name of a control during the
MouseMove event while the mouse pointer is moving over that control?

Thank you and God Bless,

Mark A. Sam
 
A

Allen Browne

Unfortunately, Access does not expose that to you. You need to code it into
the event yourself.

Whatever you are doing with the MouseMove event, you are probably calling a
function in a standard module to process it if you must do similar kinds of
things in the events of multiple controls. If you need the X and Y
co-ordinates or button states, you will need to use the event procedure to
call the generic function. If you don't care about those, you could place
the call to your generic function directlly into the On Mouse Move property
of the control, and you can do that programmatically. This kind of thing:

For each ctl in Forms!Form1.Controls
If ctl.ContolType = acTextBox Then
ctl.OnMouseMouse = "=MyFunc([" & ctl.Name & "])"
End If
Next

That's assuming that MyFunc() accepts a control as its argument:
Function MyFunc(ctl As Control)
 
M

Mark A. Sam

Hello Allen,

What I want to do is set the focus to the control that the mousepointer is
moving over. For example a button named [prevRecord]

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

[prevRecord].SetFocus

End Sub

Is there a way to read the first line of the Event Prodedure? Then I could
parse out the field name.

God Bless,

Mark



Allen Browne said:
Unfortunately, Access does not expose that to you. You need to code it
into the event yourself.

Whatever you are doing with the MouseMove event, you are probably calling
a function in a standard module to process it if you must do similar kinds
of things in the events of multiple controls. If you need the X and Y
co-ordinates or button states, you will need to use the event procedure to
call the generic function. If you don't care about those, you could place
the call to your generic function directlly into the On Mouse Move
property of the control, and you can do that programmatically. This kind
of thing:

For each ctl in Forms!Form1.Controls
If ctl.ContolType = acTextBox Then
ctl.OnMouseMouse = "=MyFunc([" & ctl.Name & "])"
End If
Next

That's assuming that MyFunc() accepts a control as its argument:
Function MyFunc(ctl As Control)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Hello,

Does anyone know a way of retriving the name of a control during the
MouseMove event while the mouse pointer is moving over that control?

Thank you and God Bless,

Mark A. Sam
 
A

Allen Browne

Unfortunately, Access does not give you that.

You have to code it manually, or programmatically assign the OnMouseMove
property as in the previous reply.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Hello Allen,

What I want to do is set the focus to the control that the mousepointer is
moving over. For example a button named [prevRecord]

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

[prevRecord].SetFocus

End Sub

Is there a way to read the first line of the Event Prodedure? Then I
could parse out the field name.

God Bless,

Mark



Allen Browne said:
Unfortunately, Access does not expose that to you. You need to code it
into the event yourself.

Whatever you are doing with the MouseMove event, you are probably calling
a function in a standard module to process it if you must do similar
kinds of things in the events of multiple controls. If you need the X and
Y co-ordinates or button states, you will need to use the event procedure
to call the generic function. If you don't care about those, you could
place the call to your generic function directlly into the On Mouse Move
property of the control, and you can do that programmatically. This kind
of thing:

For each ctl in Forms!Form1.Controls
If ctl.ContolType = acTextBox Then
ctl.OnMouseMouse = "=MyFunc([" & ctl.Name & "])"
End If
Next

That's assuming that MyFunc() accepts a control as its argument:
Function MyFunc(ctl As Control)

Mark A. Sam said:
Hello,

Does anyone know a way of retriving the name of a control during the
MouseMove event while the mouse pointer is moving over that control?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top