dbTalk Databases Forums  

Scroll records with the mouse wheel in Access7

comp.databases.ms-access comp.databases.ms-access


Discuss Scroll records with the mouse wheel in Access7 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
paii, Ron
 
Posts: n/a

Default Scroll records with the mouse wheel in Access7 - 06-22-2010 , 10:28 AM






I noticed a problem with Allen Browne's Access7 tip using the mouse wheel
event to scroll records in form view with Access 2010 beta. Access calls the
event twice for each move of the mouse wheel, which causes skipping over
records. I added code to check the count for each move of the wheel, then
count down to 1 before scrolling the records; which worked if the count is
the default of 3 on my mouse. After testing I switch the mouse driver to 6;
which required 2 turns of the mouse wheel per record. Access was not calling
the event once per count, It always called it twice. Modifying Allen's code
and placing it in the event solved the problem.

Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error Resume Next

Static iWheelCount As Integer ' Call count

' Only scroll if in form view
If Me.CurrentView = 1 And Count <> 0& Then
If iWheelCount = False Then
iWheelCount = True ' Skip 1st call to sub for each move of
mouse wheel
Exit Sub
End If
iWheelCount = False

Err.Clear
If Me.Dirty Then
Me.Dirty = False
End If
Select Case Err.Number
Case 0&: ' OK
Case 3314&, 2101&, 2115& ' can't save record
MsgBox "Cannot scroll to another record, as this one cannot
be saved", _
vbInformation, "Cannot scroll"
Exit Sub
Case Else:
MsgBox "Cannot scroll" & vbCrLf & Err.Description,
vbInformation, "Cannot scroll"
Exit Sub
End Select

Err.Clear
RunCommand IIf(Count < 0&, acCmdRecordsGoToPrevious,
acCmdRecordsGoToNext)
If Err.Number = 2046& Then ' Can't move before first or after last
Beep
End If
End If

End Sub

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.