Slide Control

  • Thread starter Thread starter Ross
  • Start date Start date
R

Ross

Has anyone used a Slide Control in a form to change a number field up/down
and if so how can I do it or where can I download the control.


Thanks in advance.

Ross
 
Hi Ross,

There's a Slider control in the Microsoft Coomon Controls; you should be
find it if you look in the More Controls list from the controls toolbox.

It's easy to use: after you drag it onto your form, you can get to its
properties via the right-click menu, and set its min and max values (and
several other properties). Or you can set the properties via code, probably
most usefully from the form's Open or Load events.

Then you can assign the value of the slider control to a field in the
current record, or to a textbox bound to a field, or to an unbound textbox,
or ... , with a single line of code:
Me.txtSliderValue = Me.ctlSlider.Value
or
Me!FieldName = Me.ctlSlider.Value

If you decide to set the slider's properties via code, you'll find that
intellisense will not expose every property; in particular, it does not
expose the .Min and .Max properties. But you can set them, like this:
Me.ctlSlider.Min = 0
Me.ctlSlider.Max = 10000

A useful tip when entering unexposed properties, if you're not sure of the
syntax, is to type everything in lowercase; if you've got it right, the case
will change to proper or camel case when you move off the line.

Compile your code before running (via the Debug menu in the Visual Basic
editor) to ensure that the appropriate reference is set; if you get an
error, check Tools | References and include the appropriate object library
(probably Microsoft Windows Common Controls 6.0 (SPx)).

HTH,

Rob
 
Rob,

Thanks for the help, it worked a treat.
It's good to see that help is only a keystroke away.

Ross
 
Another way to facilitate incrementing/decrementing a numeric field (with a
slight modification it can do dates, too) is like this:

Private Sub YourNumericField_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Or KeyAscii = 61 Then
KeyAscii = 0
Me.YourNumericField = Me.YourNumericField + 1
ElseIf KeyAscii = 45 Then
KeyAscii = 0
Me.YourNumericField = Me.YourNumericField - 1
End If
End Sub

Now, when in the field, Pressing the Minus or Plus key will add or subtract
the value by one. The line

If KeyAscii = 43 Or KeyAscii = 61 Then

allows you to press the "+" key either with or without <Shift> being pressed.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

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

Back
Top