Advance to next record with mouse wheel

G

Gerry Flinn

In Access 2003 I could qickly scroll through form records with the mouse
wheel. In Access 2007 the only way to advance seems to be Page Up or Down.
The mouse wheel does not move to the next or previous records. I can not
find a way to change setting to all this navigation method. Any ideas?

Gerry Flinn
 
A

Allen Browne

Use the MouseWheel event of the form:

Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo Err_Handler
'Purpose: In Access 2007, make the MouseWheel scroll in Form View.
' Many people found this behavior annoying, so MS removed it.
' This code lets Access 2007 behave like older versions.

'Run this only in Access 2007 and later, and only in Form view.
If (Val(SysCmd(acSysCmdAccessVer)) >= 12) And (Me.CurrentView = 1) Then
'Save any edits before moving record.
RunCommand acCmdSaveRecord
'Move back a record if Count is negative, otherwise forward.
RunCommand IIf(Count < 0&, acCmdRecordsGoToPrevious,
acCmdRecordsGoToNext)
End If

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2046& Then 'Can't move to that record
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
End Sub
 
G

Gerry Flinn

Allen,

I am not experienced in using Visual Basic, but I did paste your code into
the event builder, but I kept getting syntex errors. Do I post the entire
text you wrote or only part of it? Also one of your commands says "IIF". Is
this a typo.

Thanks for the help.

Gerry Flinn
 
A

Allen Browne

1. Open the form in design view.

2. Open the Properties box (View menu.

3. On the Events tab, set the Mouse Wheel property to:
[Event Procedure]

4. Click the Build button (...) beside the property.
Access opens the code window.
Set up the code there as shown.

If you don't see the property, you are looking at the properties of a text
box where you need to be looking at the properties of the form.
 
G

Gerry Flinn

Allen,

I got it to work. The problem with the first paste was an extra line break,
that once removed solved the problem. I never would have figured this out on
my own.

Thanks for your help.

Gerry Flinn

Allen Browne said:
1. Open the form in design view.

2. Open the Properties box (View menu.

3. On the Events tab, set the Mouse Wheel property to:
[Event Procedure]

4. Click the Build button (...) beside the property.
Access opens the code window.
Set up the code there as shown.

If you don't see the property, you are looking at the properties of a text
box where you need to be looking at the properties of the form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Gerry Flinn said:
Allen,

I am not experienced in using Visual Basic, but I did paste your code into
the event builder, but I kept getting syntex errors. Do I post the entire
text you wrote or only part of it? Also one of your commands says "IIF".
Is
this a typo.

Thanks for the help.

Gerry Flinn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top