รบกวนสอบถามเรื่อง ลูกกลิ้งที่เม้าส์
กระทู้เก่าบอร์ด อ.Yeadram

 1,452   4
URL.หัวข้อ / URL
รบกวนสอบถามเรื่อง ลูกกลิ้งที่เม้าส์

ืคือเวลาคีย์ข้อมูล แล้วมือไปกลิ้ง โดนลูกกลิ้งที่เม้าส์ทำให้ Record ข้อมูลมันเปลี่ยนไป พอจะมีคำสั่งไม่ให้ลูกกลิ้งทำงาน ขณะที่เปิดโปรแกรมเราหรือเปล่าครับ ขอบคุณครับ

4 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R13810
ไปหน้าแรกเว็บบอร์ด ค้นในช่องค้นหา Disable mouse wheel
ผมไม่เคยใช้ แต่ลองค้นดูเห็นหลายลิงค์เลยครับ ลองค้นลองอ่านดูนะครับ
2 @R13811
ขอบคุณครับ ผมเข้าไปแล้วครับเขาให้สูตรนี้มา

Public Function DoMouseWheel(frm As Form, lngCount As Long) As Integer
On Error GoTo Err_Handler
    'Purpose:   Make the MouseWheel scroll in Form View in Access 2007.
    '           This code lets Access 2007 behave like older versions.
    'Return:    1 if moved forward a record, -1 if moved back a record, 0 if not moved.
    'Author:    Allen Browne, February 2007.
    'Usage:     In the MouseWheel event procedure of the form:
    '               Call DoMouseWheel(Me, Count)
    Dim strMsg As String
    'Run this only in Access 2007 and later, and only in Form view.
    If (Val(SysCmd(acSysCmdAccessVer)) >= 12#) And (frm.CurrentView = 1) And (lngCount <> 0&) Then
        'Save any edits before moving record.
        RunCommand acCmdSaveRecord
        'Move back a record if Count is negative, otherwise forward.
        RunCommand IIf(lngCount < 0&, acCmdRecordsGoToPrevious, acCmdRecordsGoToNext)
        DoMouseWheel = Sgn(lngCount)
    End If

Exit_Handler:
    Exit Function

Err_Handler:
    Select Case Err.Number
    Case 2046&                 'Can't move before first, after last, etc.
        Beep
    Case 3314&, 2101&, 2115&   'Can't save the current record.
        strMsg = "Cannot scroll to another record, as this one can't be saved."
        MsgBox strMsg, vbInformation, "Cannot scroll"
    Case Else
        strMsg = "Error " & Err.Number & ": " & Err.Description
        MsgBox strMsg, vbInformation, "Cannot scroll"
    End Select
    Resume Exit_Handler
End Function

เวลาใช้งาน ก็เข้าไปที่ออกแบบฟอร์ม ใน Event หัวข้อ On Mouse Wheel เขียนคำสั่งนี้ใน VBA

'Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
    Call DoMouseWheel(Me, Count)
'End Sub

แต่ผมใช้กับ 2003 แล้ว Record ยังคงเลื่อนอยู่ดีครับ ที่อ่านเหมือนว่าจะใช้กับ 2010
3 @R13812
ยังไม่สามารถแก้ไขได้ครับ รบกวนใครที่แก้ปัญหานี้กับ 2003 รบกวนหน่อยครับขอบคุณครับ
4 @R13814
ทำได้แล้วครับผมไปที่ Link นี้ครับ

http://www.lebans.com/mousewheelonoff.htm

แล้วไปดาวน์โหลด์ ไฟล์ MouseWheelHookA2K.zip มาดูตัวอย่างครับ

หลักการของเขาคือเขาเขียน ไฟล์สกุล .dll ในการใช้งานควบคู่กัน แล้วเขียนคำสั่งที่ Modules แล้วใช้ปุ่มในการเรียกใช้คำสั่ง

แต่ผมดัดแปลงนิดหน่อย คือ Load From แล้ว Disable Mouse เลย
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.3303s