"Disabling" the Mouse Wheel (Access2000)

Steve R.

Retired
Local time
Today, 07:35
Joined
Jul 5, 2006
Messages
5,741
I have a data entry form where accidentally scrolling the mouse wheel creates a whole bunch of new records. How to actually disable the mouse wheel has been covered on this forum. Microsoft also has an article on this topic.

Instead I attempted to use
Code:
me.allowaddtions=false
to get around this issue. While, it did prevent the addition of new records; a new problem occurred. If the user canceled the data entry operation, a spurious record was created. Access seems to like giving you a new problem if you solve a problem. Evidently disabling the ability to add new records, forced the creation of a new record so that the
Code:
me.undo 
DoCmd.Close , , acSaveNo
commands would not work as intended.

After much experimenting I found that the spurious record can be deleted using the FORM CLOSE event when the CANCEL button is pressed.
Code:
    If Not OKtoProceed2 Then            
            Dim CDBS As DAO.Database
            Dim CRST As DAO.Recordset
            Set CDBS = CurrentDb
            Set CRST = CurrentDb.OpenRecordset("consistency", dbOpenDynaset)
            CRST.MoveFirst            
            CRST.FindFirst "[projectnum] =  " & Me.projectnum           
            CRST.Delete
            CRST.Close
            Set CRST = Nothing
            End If

The cancel button sets OKtoProceed to FALSE when clicked. While not an "elegant" solution, it does keep the mouse wheel from creating creating new records and deletes the "pending" record. Any thoughts on improvement?
 
At least one of your non-artificial fields should be required (not zero length, not null, and should probably even have a UK on it). I fear your table(s) may not be designed correctly if you can insert "blank" records.
 
At least one of your non-artificial fields should be required (not zero length, not null, and should probably even have a UK on it). I fear your table(s) may not be designed correctly if you can insert "blank" records.

My apologies for not being more clear. When the data entry form is activated a subroutine kicks-in to assign a "serial number". Furthermore, the form is populated with default values. So the form does have data in it before the user does anything. In fact, the me.undo command worked, just as long as the mouse wheel was NOT used. However, when the mouse wheel is used, the "serial number" subroutine gets activated each time a new record is created. I experimented with trying to stop the auto-generation of serial numbers resulting from the mouse wheel but was unsuccessful. Ultimately, I could add the suggested code for really disabling the mouse wheel.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom