Turn Off Scrolling

Lynn_AccessUser

Registered User.
Local time
Today, 15:25
Joined
Feb 4, 2003
Messages
125
I added the code referred to in the following article to turn off the mouse scrolling completely within Access.

http://support.microsoft.com/default.aspx?scid=kb;en-us;278379&Product=acc2000

However, my problem now is that my other code which was working before is no longer working.

For example, on the click event of a command button I had

Private Sub cmdAddNew_Click()

If IsNull(Forms!frmMain!subform!txtFieldname) Then
MsgBox "Please select an item from the list.", vbExclamation
Cancel = True
Else . . . .


The error message I am getting is a "Compile Error: Variable not defined" on the line

Cancel = True

If I dim Cancel As Integer then the button doesn't work at all. No error message, but it doesn't do anything either. If I remove all of the code for turning off the mouse scroll my button works.

Oh yea, the code for turning off the mouse scroll works even though my other code no longer does.

Thanks for the help!!
 
In order to use Cancel = True, the Cancel parameter needs to be defined for the event and Cancel is NOT defined for the button click event. When the Cancel parm is defined, you will see it in the parameter list of the sub's header. For example the BeforeUpdate event supports the Cancel parm. Your code as written could never have worked.
 
Why would you use Cancel in your if statement. If the if statement returns false the record won'd be added anyway. Take out your Cancel
 
Pat, do you mean the code would not work with the code to turn off the scrolling or did you mean in general. Just wondering, because the code did work before I added the code to turn off the scrolling which why I do not understand why the cancel = True is a problem now on the other events.

MadMaxx, sorry I should have included the rest of the code. If the field is not null then the command button actually closes the form and opens to a different form that is designed slightly different for data entry of a new record which is why I have an else statement.
 
Lynn_AccessUser said:
Private Sub cmdAddNew_Click()

If IsNull(Forms!frmMain!subform!txtFieldname) Then
MsgBox "Please select an item from the list.", vbExclamation
Cancel = True
Else . . . .
Instead of the Cancel = True, I would just exit the sub...
Code:
If IsNull(Forms!frmMain!subform!txtFieldname) Then
MsgBox "Please select an item from the list.", vbExclamation
Exit Sub
Else . . . .
Also, check out the nomouse.zip sample I posted [it is near the bottom of the page] for it allows you to easily turn on or off the mouse scroll wheel and it does not mess my other subs or functions up.

You might benefit from my A Better Mouse Trap? sample for that is my prefered way to ensure that a user has saved a modified record before they can move to another record or close the form.

HTH
 

Users who are viewing this thread

Back
Top Bottom