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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a command button act in a scroll button way? 3

Status
Not open for further replies.

inso18

Technical User
Dec 30, 2006
147
IL
Hello all.

Does anyone knows if it is possible and how to code a command button so it will continuously perform a command (for ex. x = x + 1), in a similar way a scroll button works?

Thanks.
 
You could play with the timer:

Code:
Option Compare Database
Dim blnOn

Private Sub cmdCommand_Click()
If blnOn = True Then
    Me.TimerInterval = 0
Else
    blnOn = True
    Me.TimerInterval = 5
End If
End Sub

Private Sub Form_Timer()
    Me.txtText = Nz(Me.txtText, 0) + 1
End Sub
 
Yes, but why? There are probably better ways to make the interface.

You could use a static variable or public variable. In this example I use the tag property

Private Sub cmdScroll_Click()
Dim intX As Integer
intX = Int(Val(cmdScroll.Tag))
cmdScroll.Tag = CStr(intX + 1)
MsgBox cmdScroll.Tag
End Sub
 
Also if you look under "more controls" you can add a slider, or scroll to a form.
 
You're talking about the AutoRepeat Property of a command button. Properties - Other - AutoRepeat. The only thing it won't work for is moving to another record. From Access Help:

"The initial repeat of the event procedure or macro occurs 0.5 seconds after it first runs. Subsequent repeats occur either 0.25 seconds apart or the duration of the event procedure or macro, whichever is longer.

If the code attached to the command button causes the current record to change, the AutoRepeat property has no effect.

If the code attached to the command button causes changes to another control on a form, use the DoEvents function to ensure proper screen updating."



The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
How are ya inso18 . . .

As you can see . . . a number of ways to do what you want have already been presented. [blue]We can help you better if you tell us how you actually intend to use this schema.[/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hi all.

Thanks for the help.

In my forum, there's a field with a number data, and a "+" and "-" button which add 1 or subtract 1 from it.

missinglinq, thanks for showing me there's such a thing as Autorepeat property. It does work. It works real fast though. Is there a way to slow it down, make it act like a button acts in an average software?
 
Missinglinq - you taught me something new about the AutoRepeat - I never knew it was there. Have a star on me!

 
It's what I find so fascinating about Access; no matter how many years you've worked with it there's always something new to learn!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top