nazemmazem
پنج شنبه 02 اردیبهشت 1389, 04:21 صبح
این راه را از اینجا پیدا کردم
http://database.itags.org/ms-access-database/57590/
منطقی تر و مناسب ترست از راههای که قبلا درباره اش صحبت شده
به نظرم رسید ممکن است به کار بعضی دوستان که مثل من نمیخواهند از OCX استفاده کنند بخورد
ولی فقط در
Single Form
قابل استفاده است
Add a Text Box on your form:
Name = NoMouseWheel
Default Value = " "
Validation Rule = WheelSpin() = False
Validation Text = You can't change records using your mouse wheel. (this can
be left out if you don't want a message)
Visible = Yes
Enabled = Yes
Locked = No
Tab Stop = No
Back style = Transparent
Back Color = -2147483633 (or whatever color your form is)
Special Effect = Flat
Border style = Transparent
FORM EVENTS:
On Mouse Wheel: [Event Procedure]
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo GotError
mWheel = True
ValidationTrigger = TheWheel
Me.NoMouseWheel.SetFocus
Me.NoMouseWheel.Text = " "
ExitSub:
ValidationTrigger = NotTheWheel
Exit Sub
GotError:
MsgBox Err.Number & vbCrLf & Err.Description
Resume ExitSub
End Sub
On Error: [Event Procedure]
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' MsgBox DataErr
If Screen.ActiveControl.Name = "NoMouseWheel" Then
Response = acDataErrContinue
End If
End Sub
ADD THIS CODE BEHIND YOUR FORM:
Option Compare Database
Option Explicit
'This Enum is for clarifying the code
Private Enum wsTrigger
TheWheel = 1
NotTheWheel = 2
End Enum
Private mWheel As Boolean
Private ValidationTrigger As wsTrigger
Private Function WheelSpin() As Integer
'used in NoMouseWheel text box on form
WheelSpin = mWheel
Select Case ValidationTrigger
Case NotTheWheel
mWheel = False
End Select
End Function
FORM EVENTS:
Key Preview = Yes
On Key Down: [Event Procedure]
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'Form's Key Preview set to Yes
If KeyCode = vbKeyPageUp Then KeyCode = 0
If KeyCode = vbKeyPageDown Then KeyCode = 0
End Sub
فایل ضمیمه را ببینید
http://database.itags.org/ms-access-database/57590/
منطقی تر و مناسب ترست از راههای که قبلا درباره اش صحبت شده
به نظرم رسید ممکن است به کار بعضی دوستان که مثل من نمیخواهند از OCX استفاده کنند بخورد
ولی فقط در
Single Form
قابل استفاده است
Add a Text Box on your form:
Name = NoMouseWheel
Default Value = " "
Validation Rule = WheelSpin() = False
Validation Text = You can't change records using your mouse wheel. (this can
be left out if you don't want a message)
Visible = Yes
Enabled = Yes
Locked = No
Tab Stop = No
Back style = Transparent
Back Color = -2147483633 (or whatever color your form is)
Special Effect = Flat
Border style = Transparent
FORM EVENTS:
On Mouse Wheel: [Event Procedure]
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo GotError
mWheel = True
ValidationTrigger = TheWheel
Me.NoMouseWheel.SetFocus
Me.NoMouseWheel.Text = " "
ExitSub:
ValidationTrigger = NotTheWheel
Exit Sub
GotError:
MsgBox Err.Number & vbCrLf & Err.Description
Resume ExitSub
End Sub
On Error: [Event Procedure]
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' MsgBox DataErr
If Screen.ActiveControl.Name = "NoMouseWheel" Then
Response = acDataErrContinue
End If
End Sub
ADD THIS CODE BEHIND YOUR FORM:
Option Compare Database
Option Explicit
'This Enum is for clarifying the code
Private Enum wsTrigger
TheWheel = 1
NotTheWheel = 2
End Enum
Private mWheel As Boolean
Private ValidationTrigger As wsTrigger
Private Function WheelSpin() As Integer
'used in NoMouseWheel text box on form
WheelSpin = mWheel
Select Case ValidationTrigger
Case NotTheWheel
mWheel = False
End Select
End Function
FORM EVENTS:
Key Preview = Yes
On Key Down: [Event Procedure]
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'Form's Key Preview set to Yes
If KeyCode = vbKeyPageUp Then KeyCode = 0
If KeyCode = vbKeyPageDown Then KeyCode = 0
End Sub
فایل ضمیمه را ببینید