Using Mousewheel to run query in textbox

flect

Registered User.
Local time
Today, 19:18
Joined
Feb 26, 2008
Messages
86
Hello

Does anyone know if it's at all possible to program the mousewheel to run a query in a textbox

ie - i would like to update the quantity of stock +/- 1 by scrolling up or down within the textbox

i'm thinking along the lines of

Code:
Private Sub StockEnv_MouseWheel()
DoCmd.OpenQuery "plusone", acViewNormal, acEdit
but how is it possible to distiguish between scrolling up or down?

I haven't been able to find anything useful on google - most of the info is on how to disable the mousewheel.
 
I looked into it once - figured my time was too valuable :D so implemented a slider bar as a workaround to get the +/- 1 action.

-dK
 
I looked into this a bit more and discovered something ....

On the form, you can use the form's event. For example, suppose you had a control called txtSomeNumber on a form. Then you could use the following ...

Code:
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
If Me.ActiveControl.Name = "txtSomeNumber" Then
    Me.txtSomeNumber = Me.txtSomeNumber + (Count / 3)
End If

On the very limited testing that I've done, a wheel 'click' is equal to a value of the 3, hence the /3 to move the control +/- 1. The Count variable is to determine how many lines the page should move.

The ActiveControl bit prevents the field from updating if you have scrollbars on the form and use the mousewheel to move up and down, so the control must have the focus in order for the mousewheel trick to work. The If can be removed if you can guarentee no scroll bars.

Anyhow - it is not foolproof by any means - just a proof of concept - certainly not of validity because it depends on how you run your forms (for instance - allow adds = false, view current record only, etc.) if this technique could be utilized or not.

-dK
 
Wow!!!!!

Spot on. I've just tested it with my home db and it works brilliantly!

I'll play with it some more and then put it in at work on monday and post some results.

I think this will really open up some new avenues for interface design - seeing as most of the staff are lazy and don't like taking their hand off the mouse to type :-D

awesome stuff!

Code:
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
If Me.ActiveControl.Name = "StockEnv" Then
    Me.StockEnv = Me.StockEnv + (Count / -3)
End If
If Me.ActiveControl.Name = "StockFold" Then
    Me.StockFold = Me.StockFold + (Count / -3)
End If
If Me.ActiveControl.Name = "StockCpt" Then
    Me.StockCpt = Me.StockCpt + (Count / -3)
End If
    
End Sub
 
Last edited:
Glad it works :), although it should come with a word of caution. This technique does not intercept the mouse wheel for your use without the mouse wheel continuing to run its normal events - form scrolling, record advancing, etc.

I think if you wanted something that was true event for this, you would probably need to do a search on 'disabling mouse wheel for access' in your favorite internet search tool. That code could probably be modified to trap the mouse wheel for specific purposes.

-dK
 
Glad it works :), although it should come with a word of caution. This technique does not intercept the mouse wheel for your use without the mouse wheel continuing to run its normal events - form scrolling, record advancing, etc.

I think if you wanted something that was true event for this, you would probably need to do a search on 'disabling mouse wheel for access' in your favorite internet search tool. That code could probably be modified to trap the mouse wheel for specific purposes.

-dK

This isn't really a problem for me as the controls are on a subform - the only problem now i have is returning focus to the appropriate control after the record is saved.

Code:
If Me.ActiveControl.Name = "StockEnv" Then
    Me.StockEnv = Me.StockEnv + (Count / -3)
runcommand acCmdSaveRecord
StockEnv.SetFocus
End If

only flashes focus on the control then goes back to the tab order default.

:confused:

mouse works brilliantly though :D
 
Hmmmm .. not for sure, but try:

Code:
DoCmd.RunCommand acCmdSaveRecord

-dK
 

Users who are viewing this thread

Back
Top Bottom