Looping OnClick or OnKeyPress

M

magmike

I have a subform that is continuous, but only shows the records
related to a company (not important really).

On that subform I have buttons for scrolling (I don't like the way
scroll bars reserve the space when there isn't a need for a scrollbar
and you can't control the color of the reserved space - it's a
personal aesthetic idiosyncrasy) and the code behind the "up" button,
for example, is this:

Private Sub Command8_Click()

Dim nControl As String
nControl = "nText"

DoCmd.GoToControl nControl
DoCmd.GoToRecord , , acPrev

End Sub

How can I code it to continue going through previous records if the
user presses the command button and holds it down?

Thanks in advance!

magmike
 
M

Mark

Hi, I agree on the [poor] aesthetics of the scroll bar but I've grown to
live with it and now always make sure it's visible and accommodate for it's
space... at least the look is consistent.

To get repeating code on a button you could try a mousedown or keydown event
and use with a 1 sec delay so your navigation keeps getting repeated every 1
sec or something until you see a mouseup or keyup. Haven't tried but worth a
look. If not, then maybe a mousemove event so hovering over a control will
trigger your code.

Mark
 
M

magmike

Hi, I agree on the [poor] aesthetics of the scroll bar but I've grown to
live with it and now always make sure it's visible and accommodate for it's
space... at least the look is consistent.

To get repeating code on a button you could try a mousedown or keydown event
and use with a 1 sec delay so your navigation keeps getting repeated every1
sec or something until you see a mouseup or keyup. Haven't tried but wortha
look. If not, then maybe a mousemove event so hovering over a control will
trigger your code.

Mark




I have a subform that is continuous, but only shows the records
related to a company (not important really).
On that subform I have buttons for scrolling (I don't like the way
scroll bars reserve the space when there isn't a need for a scrollbar
and you can't control the color of the reserved space - it's a
personal aesthetic idiosyncrasy) and the code behind the "up" button,
for example, is this:
Private Sub Command8_Click()
Dim nControl As String
nControl = "nText"
DoCmd.GoToControl nControl
DoCmd.GoToRecord , , acPrev
How can I code it to continue going through previous records if the
user presses the command button and holds it down?
Thanks in advance!
magmike- Hide quoted text -

- Show quoted text -

Sounds great. Being a novice though, how would you code the 1 second
delay to have the function restart, and then how would I code the
mousemove to stop the keydown event?

thanks...
 
M

Mark

Try...

Public Sub DelayTime(intSeconds As Integer)
On Error GoTo Err_Handler

Dim PauseTime, Start, Finish, TotalTime

'Debug.Print "Paused " & Time()
PauseTime = intSeconds ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
'Debug.Print Time()
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
'Debug.Print "Resumed " & Time()
'MsgBox "Paused for " & TotalTime & " seconds"

Exit_Sub:
Exit Sub

Err_Handler:
Resume Exit_Sub

End Sub


Usage:

DelayTime(1) ' delay 1 second



Hi, I agree on the [poor] aesthetics of the scroll bar but I've grown to
live with it and now always make sure it's visible and accommodate for
it's
space... at least the look is consistent.

To get repeating code on a button you could try a mousedown or keydown
event
and use with a 1 sec delay so your navigation keeps getting repeated every
1
sec or something until you see a mouseup or keyup. Haven't tried but worth
a
look. If not, then maybe a mousemove event so hovering over a control will
trigger your code.

Mark




I have a subform that is continuous, but only shows the records
related to a company (not important really).
On that subform I have buttons for scrolling (I don't like the way
scroll bars reserve the space when there isn't a need for a scrollbar
and you can't control the color of the reserved space - it's a
personal aesthetic idiosyncrasy) and the code behind the "up" button,
for example, is this:
Private Sub Command8_Click()
Dim nControl As String
nControl = "nText"
DoCmd.GoToControl nControl
DoCmd.GoToRecord , , acPrev
How can I code it to continue going through previous records if the
user presses the command button and holds it down?
Thanks in advance!
magmike- Hide quoted text -

- Show quoted text -

Sounds great. Being a novice though, how would you code the 1 second
delay to have the function restart, and then how would I code the
mousemove to stop the keydown event?

thanks...
 

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

Similar Threads


Top