WFBweb
asked on
Access 2007 MouseWheel event shifts open form
I've been enhancing an Access 2000 system. Before I started, forms opened via a switchboard. They were set up to open on the latest record. If users wanted to find a different record they would just scroll until they found it.
When I modified the system, they asked for the ability to selectively turn the mouse scrolling on and off. I set up a combo box to do this and used Stephen LeBans MouseWheelOnOff processing.
Now I'm taking the system to Access 2007. I figured I would no longer need the MouseWheelOnOff process because 2007 has a MouseWheel event for forms.
Below is logic I found on a Microsoft forum with a modification I made for turning the wheel off. It works fine except for one major problem. When I mousewheel down, not only does the next earliest record appear, the form moves down about 5-6 lines with each turn of the wheel until the bottom of the form shows up. Since the basic info about the record is at the very top of the form this means that if the user is looking for a particular record he has to keep scrolling back up to the top after each mousewheel down. Everything works fine with mousewheel up.
I placed a very small textbox in the top left corner of the form and after each downward movement, I placed logic to set focus on it, but even with echo off, it's a jittery nuisance and for some reason you still can't see the very top of the form. How do I prevent movement from the top of the form to the bottom?
By the way, the form doesn't have a header or footer....only the detail section.
WheelLogic.docx
When I modified the system, they asked for the ability to selectively turn the mouse scrolling on and off. I set up a combo box to do this and used Stephen LeBans MouseWheelOnOff processing.
Now I'm taking the system to Access 2007. I figured I would no longer need the MouseWheelOnOff process because 2007 has a MouseWheel event for forms.
Below is logic I found on a Microsoft forum with a modification I made for turning the wheel off. It works fine except for one major problem. When I mousewheel down, not only does the next earliest record appear, the form moves down about 5-6 lines with each turn of the wheel until the bottom of the form shows up. Since the basic info about the record is at the very top of the form this means that if the user is looking for a particular record he has to keep scrolling back up to the top after each mousewheel down. Everything works fine with mousewheel up.
I placed a very small textbox in the top left corner of the form and after each downward movement, I placed logic to set focus on it, but even with echo off, it's a jittery nuisance and for some reason you still can't see the very top of the form. How do I prevent movement from the top of the form to the bottom?
By the way, the form doesn't have a header or footer....only the detail section.
WheelLogic.docx
ASKER
Unless I'm misreading your ref, it only applies to Access 2000 and Access 97.
The Access 2000 version should work in any version >=A2000.
If you have any issue, let me know and I will contact Wayne.
mx
If you have any issue, let me know and I will contact Wayne.
mx
ASKER
I appreciate your pointing me in a different direction than the 2007 mouse wheel event, but I'd really like to find out why it isn't working properly. I can always return to Stephen Lebans logic since I'm familiar with it, but I'd really like to get the mouse wheel event to work.
Sorry, I have never used the mousewheel event before.
mx
mx
I believe the MouseWheel event is behaving the way it's meant to. This event fires whenever the mouse wheel is used in a form view (and other views as well). You can use this event to run a process; however, this does not stop it from performing its default function --namely, to move the form up or down as applicable.
If you can fit all the controls on the form in the visible screen area so that there would be no need to scroll, you can achieve what you want. I have a feeling though that you have too many controls to fit the screen. In that case, you would have to go back to Leban's method, or use a Tab control and group similar controls on the same page. This way, your form will not be larger than your screen.
If you can fit all the controls on the form in the visible screen area so that there would be no need to scroll, you can achieve what you want. I have a feeling though that you have too many controls to fit the screen. In that case, you would have to go back to Leban's method, or use a Tab control and group similar controls on the same page. This way, your form will not be larger than your screen.
ASKER
After much effort I have to believe what you say. I'm extremely bullheaded sometimes and have spent many hours trying to prevent or reverse the last MouseWheel push down, but apparently it is the very last thing done in the MouseWheel event. If you place any kind of setfocus within the event code, the control does indeed get the focus, but after that the push down occurs.
However, it's amazing that until your words, I found nothing to say that the MouseWheel event wasn't the greatest thing ever.
However, it's amazing that until your words, I found nothing to say that the MouseWheel event wasn't the greatest thing ever.
ASKER
I'm going to leave this question open for a while in case someone knows about some vba that will force the very top part of the form to appear after a down wheel.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Kudos! I must have spent a good week on this and, just this morning, I decided to change the long forms to tab controls. I haven't worked with them since Access 2 so I was having a real learning curve. Now I'll forget about that chore....particularly because there is more than one long form to work on. Your code works great! Thank your!
New Approach - no DLL required.
http://www.everythingaccess.com/tutorials.asp?ID=A-new-method-for-disabling-the-Mouse-Scroll-Wheel-in-Access-forms
mx