Hi there. I need help with a little problem.
I have a program that creates/maintains a database with bunch of records. The problem is that there are many records, and if i want to get to lets say record 30, i need to click on my NEXT button 30 times. My question is, is there a way to keep scrolling once the user pushes and doesnt release the NEXT button? I found a way, not sure if thats the best way - i used a timer. Heres a piece of code that i used to make that happen.
Private Sub cmdNext_Click()
'Checking for END OF FILE
'if not, then show the next record
If rs.EOF = False Then
rs.MoveNext
Else
'if this is END OF FILE, then imitate a click on a button
'that moves the current position to first record
cmdFirst_Click
End If
'Checking for position after the MoveNext command
'intTotal holds the total number of records
If rs.AbsolutePosition < 0 Then cmdFirst_Click
If rs.AbsolutePosition >= intTotal Then cmdLast_Click
'RefreshDat sub updates all the fields with the data
'from the record in the current position
Call RefreshDat
End Sub
Private Sub cmdNext_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)
'Initialise timer
Timer1.Enabled = True
End Sub
Private Sub cmdNext_MouseUp(button As Integer, Shift As Integer, X As Single, Y As Single)
'timer off
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
cmdNext_Click
End Sub
I set the Interval property of timer1 to 100 so that the scrolling doesnt go too fast. This works, of course, only with the next button. I can make it work with the previous button too - with a global boolean variable i guess. The question is - is there an easier way to do the task? I tried playing around with the mousedown/mousemove events, but no luck so far.
Thanks for any help!
James R.