Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wheel on mouse changes records on form???? 4

Status
Not open for further replies.

chrisaroundtown

Technical User
Jan 9, 2003
122
0
0
AU
Hi,

I have a form with users entering data into a table. If you tab through the fields the form changes records to the next, or previous, record in the table. I overcame this problem by changing the "cycle" property on the form to "current page". However, users with a wheel on their mouse have the same problem when they scroll down using the wheel.

Any ideas on how I can prevent users from accessing other records using the wheel on their mouse?

Thanks
Chris.
 
See this Article on Microsoft's web site:

ACC2000: How to Detect and Prevent the Mouse Wheel from Scrolling Through Records in a Form (Q278379)

There may something in the Tek-Tips FAQs also. If you post an email address, I may have a zip file I can send you.

Have a great day!
 
Thanks,

It would be great if you could send the file to chris.merry@carlson.com


Thanks
Chris
 
May I get this information also? I am the one with the mouse wheel and find it annoying to forget I can't use it without changing records.

Please send it to:

lena.wood@hotmail.com or lena.wood@starband.net

Thanks! Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

lena.wood@starband.net
 
The easiest way to solve that problem is to get a mouse with no mouse wheel. I'll try to email the code some time this weekend. It is not my code.

 
The MS knowledge base article and the this FAQ do not work with MS Access 2000/XP SP-1, ADP project beyond a single form. Have several forms and sub forms and watch those solutions fall apart fast. Does anyone have any working code that will just turn off that wheel???????? I don't care if the user has to reboot to get their wheel back-why you ask-just try this: Create a new record, enter enough data to make a valid record, then spin the mouse wheel-you hope the user has seen the problem before they jump to a new form that was dependent on the first record
 
I'm using the pure VB solution and it works BUT problems DO occur sometimes when I load the form with the code in it. Like Microsoft suggest in the knowledge base page ... you may want to go with the other solution. I've never made a DLL before .... I hope it isnt a terrible hassle. Hope that steers you in the right direction. (^_^)

-Jedi420
 
Go to: and look under his side menu Developer>Downloads>Mousetrap. It's an ActiveX control that will stop the mouse wheel from scrolling through records on whatever form you put it on. You need to unzip it and register it in your Access, but for me it was well worth it!! As far as distribution of the program goes, you need to register it with every user's Access, but I just wrote a batch file to do that at the same time I created the shortcut to the program. Again, it's well worth it!! Such an easy solution, I've been using it for months, and haven't had a single problem with it!
 
Worked for me too

----
A program is a spell cast over a computer, turning input into error messages.
 
Hi,

Do you guys know if an event is fired off whenever you scroll to a new record with the mouse? I've been testing out most of the form's events, but so far nothing. I need to update some labels each time a new record is presented because my boss LIKES being able to scroll records instead of Next and Previous buttons. Any ideas or suggestions? Thank you (^_^)

-Jedi420
 
As an aside ... The labels are in a subform and the scrolling controls the record navigation for the main form. For some reason, when there are no records on the subform for the particular main record, the Current() event isnt triggered. I just found out that I can always use the MAIN forms current() and just access the label through the Forms Object. If you have anything to add ... feel free! (^_^)

-Jedi420
 
Here's a technique I've used before; it's clumsy, but it will not only prevent the Scroll Wheel from taking you to the next record, but also any navigation keys like Page Up, Page Down, or Ctrl+Home or End.

If the field you are in has an on Exit event that affects the content of any field, the navigation events will not move you to another record. If you've got no other way to prevent it, then, you could give each field on a Form an On Exit event along the lines of:

Me.FieldName = Me.FieldName

It's not an optimal solution, by any means, but it works, and it's easy.
 
That is pretty darn cool! Too bad you gotta do it for every field :-(. Still ... itll work in a pinch (which I am not in right now). how did you find that out ... just messing around with the code or something?

-Jedi420
 
I found it entirely by accident. I was using the Page Up and Down keys to scroll through a database, and I noticed at one point it suddenly stopped working. I soon figured out that it only stopped when I was on one particular field, and that this particular field had code which was populating a couple of other fields. I tried a few other On Exit events, but the only ones that worked were those which actually affected the contents of cells.

Come to think of it, though, I've never tried it with SetFocus events. I wonder if that would work...
 
I just tested this idea and it works nicely:

Assumption: the form is a data entry form...

In the form's OnCurrent event check to see if its a new record and if its not, go to the new record:

If Not Me.NewRecord Then
DoCmd.GoToRecord , , acLast
End If

The result is that as the user scrolls up, the OnCurrent code keeps sending him or her back to the last record they entered. And of course as the user scrolls down it just goes to the new record.

This method allows the user to edit the last record they were on, in case they hit the scroll wheel by accident.

If you want the user to be taken to the new record each and every time the wheel is moved, then use this code:

If Not Me.NewRecord Then
DoCmd.GoToRecord , , acNewRec
End If

But as I said, if the user accidentally hits the wheel, they'd be stuck on the new record, unable to return to the record they were entering.

If my initial assumption is wrong - that its not a data entry form, then my solution would be to set the recordsource to only the record(s) you want the user to have access to.
 
Whoops. Small typo. My first example goes to the LAST record rather than the NEW record - ie: if the user was in the middle of entering a new record and accidentally hit the wheel, you want to let the user go back to that record and finish it.
 
AlienGuy - great solution. I took your idea and made it into a public sub because I wanted it to add some conditions on when it would come into play. I only want it in effect when my form is in edit mode (spInEdit = True) and I wanted to then add error trapping as well.
This code goes into a module and you pass it the form. It gets the control name from whatever is the active control on that form at the time. And of course, if you are exiting a field, that is the active control on the form. The code that goes behind each field is VERY brief, yet I can turn it off and on at will :)
'----------------------
Public Sub StopIT(ThisForm As Form)
If spInEdit = True Then
Dim ctl As control
Dim strFieldName As String
Set ctl = Screen.ActiveControl
strFieldName = ctl.Name
ThisForm(strFieldName) = ThisForm(strFieldName)
End If
End Sub
'---------------------------------------------------
'fForm is a variable referencing the active form.
'-------------------------------------------------
Private Sub txtState_Exit(Cancel As Integer)
StopIT fForm
End Sub
'-----------------------------------------------
I made my form a variable to speed things up
'------------------------------------------------
Dim fForm As Form
Set fForm = Form_SearchPersons
'----------------------------------
I haven't had any problems (yet) with doing it this way.
Thanks again, AlienGuy!
NorthNone
 
A caution: AlienRay's method effectively disables the me.dirty feature.
The the form will never have
me.dirty = false
due to the code on exit of each field.
NorthNone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top