Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving through records using the mouse

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
I created my own navigation buttons to move forward and backwards in a table on a form.

The buttons work just fine but you have to keep clicking the mouse to move forward or backwards. I want to be able to scroll through the records quickly by holding down the mouse button and have the scrolling stop when I let up on the mouse button.

I used the button wizard to create the Record Navigation buttons so there are procedures available but I can't figure out how to get this to work.

Any ideas?

Thank you.
 
Hi,

I dind't test it but maybe it works.

Use the mouse_down event.....
Grtz,

Kalin
 
Hi Kanin;

I guess what I am asking is what code would you use? I tried to loop it in the mouse down event until the mouse up event happened but that didn't work. It just keeps looping and looping and looping...
 
Create a form with three controls:
1) a label named statusLabel
2) two toggle buttons (NOT command buttons)
named MoveLeftButton and MoveRightButton.

Add the following code to your form:

Option Compare Database
Option Explicit

Dim TheAction As Integer
Const c_Action_None = 0
Const c_Action_MoveLeft = 1
Const c_Action_MoveRight = 2

Dim LeftCounter As Long
Dim RightCounter As Long
Dim PrevErrNumber As Integer

' clear counters and action
' NOTE counters are just for your amusement
Private Sub Form_Open(Cancel As Integer)
LeftCounter = 0
RightCounter = 0
TheAction = 0
End Sub

' ADD this event procedure
Private Sub Form_Timer()
On Error GoTo Form_TimerError
Select Case TheAction
Case c_Action_MoveLeft
Me.statusLabel.Caption = "move left " & LeftCounter
LeftCounter = LeftCounter + 1
DoCmd.GoToRecord , , acPrevious
Case c_Action_MoveRight
Me.statusLabel.Caption = "move right " & RightCounter
RightCounter = RightCounter + 1
DoCmd.GoToRecord , , acNext
End Select

Form_TimerExit:
Exit Sub

Form_TimerError:
If Err.Number <> PrevErrNumber Then
MsgBox Err.Number & &quot;, &quot; & Err.Description
PrevErrNumber = Err.Number
End If
Resume Form_TimerExit
End Sub

' ADD this event procedure
Private Sub MoveLeftButton_Click()
If Nz(Me.MoveLeftButton, False) Then
If Nz(Me.MoveRightButton, False) Then
Me.MoveRightButton = False
End If
TheAction = c_Action_MoveLeft
Else
TheAction = c_Action_None
End If
End Sub

' ADD this event procedure
Private Sub MoveRightButton_Click()
If Nz(Me.MoveRightButton, False) Then
If Nz(Me.MoveLeftButton, False) Then
Me.MoveLeftButton = False
End If
TheAction = c_Action_MoveRight
Else
TheAction = c_Action_None
End If
End Sub
 
Well,

what I would do is the following....

Create an procedure for mouse_down set a variable Mousedown to TRUE.
Create an procedure for mouse_up set a variable Mousedown to FALSE.

Set your form_timer to the interval on which you want to check if the mouse is still down.....

Create a on_timer event in which you check your variable and if it's down scroll a record forward/backward.

Grtz,

Kalin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top