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
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
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.
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?
Instead I attempted to use
Code:
me.allowaddtions=false
Code:
me.undo
DoCmd.Close , , acSaveNo
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?