On/Off control for continuous form (1 Viewer)

CJ_London

Super Moderator
Staff member
Local time
Today, 10:57
Joined
Feb 19, 2013
Messages
16,612
Some time ago Isladogs developed a suggestion of mine for a toggle button - https://www.isladogs.co.uk/on-off-toggle/

This was then taken up by Mike Wolfe and further improved by Steve Halder - https://nolongerset.com/triple-state-modern-on-off-switch/

Problem is, it doesn't work well with a continuous form, so I thought I would see if it was possible. This is my solution. There are 3 versions, simple, triple and mouseover.

Note that this will not work with a scrollable continuous form - it uses the absoluteposition property. Further work would be required to take account of the scroll position to modify this position, so can be done, I just haven't done it for this example.

The button can mean what you like 'yes/no', 'on/off', 'agree/disagree', 'choose left/choose right', just depends on the context. This example is based on 'choose left/choose right'

an example of the simple version. Just click on the control to switch between left and right
1661254523144.png


for the triple state, there is a middle position which might mean don't know/don't care/use default/undecided. For this click on the left, right or middle of the control to switch between options. In the code there is an alternative so the user can step through the options on each click if that is the preferred behavior.
1661254662879.png

finally there is the mouseover effect - the relevant control is highlighted when the mouse is over the relevant control. Note I've increased the spacing slightly to ensure the relevant code can fire. This otherwise works the same way as the triple state.
1661254768919.png

The control is an image - you will find the images in the msysResources table, or you can build your own. These were made using a button with the font set to webdings and the character chr(110)- lowercase n. There are other fonts and characters you can use instead. For example in wingdings 3 these are chr(133) and chr(134) respectively. and chr(152) in webdings. Plenty to choose from.


1661257417590.png
1661257564373.png


All three forms work off the same table - so if you choose a triple option and return to the simple form, this is not a bug :) it may be that the selection does not match - just click where the control is and the control will reappear. In a real situation, you would have consistency with the values.
 

Attachments

  • ContinuousOnOff.accdb
    544 KB · Views: 205
Last edited:

KitaYama

Well-known member
Local time
Today, 18:57
Joined
Jan 6, 2022
Messages
1,541
When I first saw modern on off toggle button post, I decided to use it in one of my apps. but when I noticed the screen flickering because of these controls, I stopped using them.

Your version has the same effect. Is there any way to stop screen flickering?
A video is attached that shows the situation.

Thanks.
 

Attachments

  • 2022-08-23_21-49-00.zip
    684.3 KB · Views: 174
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 10:57
Joined
Feb 19, 2013
Messages
16,612
I've take a look at your video, but don't experience the flicker you demonstrate - I was able to stop it around 7 seconds in and see this
image_2022-08-23_141842946.png

There is a bit of flicker on the mouseover form but I have no idea why you are seeing this on the triple form. Do you also get it on the simple form?

You can try moving the image mouseup code to mousedown, or use the alternative code to change the selection value in the click event.
Also try using requery or refresh rather than recalc, although I've just tried that and there was definite flicker. And perhaps comment out the painting code?

However now you mention it I do sometimes get a a flicker if I look very carefully but not always - and a lot faster that your video, I hadn't even noticed it

Will be interested to know if others experience the same problem
 

isladogs

MVP / VIP
Local time
Today, 10:57
Joined
Jan 14, 2017
Messages
18,225
I think the flickering issue is caused because there are 2 or more forms open on top of each other
Altering the control state on one form changes it on the other open forms and the change 'bleeds through' causing the flicker.
You can see this happening by moving the forms so they are alongside each other

The flickering is almost completely eliminated if you only have one form open at a time.

Hope that helps
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:57
Joined
Feb 19, 2013
Messages
16,612
I've created an alternative triple form based on the format property as described in the colourful checkbox thread https://www.access-programmers.co.u...s-a-resizeable-and-colourful-checkbox.305659/

This does not require any refreshing of the form and appears to me to not flicker at all. You don't have so many presentation options in terms of using gradients or alternative back colours - so to indicate 'don't know, I used a different colour
1661270570996.png

It also can't be 'upgraded' to use a mouseover effect, at least not without reintroducing images.

@KitaYama - please give this a try

@isladogs - yes that could be it.

Please find updated file attached
 

Attachments

  • ContinuousOnOff r1.zip
    56.3 KB · Views: 199

isladogs

MVP / VIP
Local time
Today, 10:57
Joined
Jan 14, 2017
Messages
18,225
Whilst I like the latest form, I've noticed a problem on both this & the earlier version where the forms affect each other

If you switch any button off on one form it now disappears on the other forms.
Obviously that wouldn't happen in a real app as you would only use one of these at a time!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:57
Joined
Feb 19, 2013
Messages
16,612
Agreed - I did mention it in the first post :)
All three forms work off the same table - so if you choose a triple option and return to the simple form, this is not a bug :) it may be that the selection does not match - just click where the control is and the control will reappear. In a real situation, you would have consistency with the values.
The option for values varies from form to form

in the single it is 0 and 1
for the triple and mouseover it is 0, 1 and 2
for the triple format it is -1, 0 and 1
but they have different meanings

So if a row has 2 assigned to it it won't appear in the single or triple format and a -1 won't appear in single, triple or mouseover.

0's and 1's should appear, but they may not indicate the same left or right
 

isladogs

MVP / VIP
Local time
Today, 10:57
Joined
Jan 14, 2017
Messages
18,225
Apologies - I hadn't read that properly before! (y)

For me, the main use of this control is in an application settings form

For info, I've just alerted Mike Wolfe to this new thread
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 10:57
Joined
Feb 19, 2013
Messages
16,612
For me, the main use of this control is in an application settings form

Absolutely - or a questionaire of some sort....

Thanks for alerting Mike

incidentally, you can go to more than 3 values if you wanted - would need to be wider but could then be used for levels or size - level of certainty, scores out of 5, font size, degree of boldness, brightness, etc, though there may be better tools out there for that.
 
Last edited:

NoLongerSet

Member
Local time
Today, 05:57
Joined
Jul 13, 2021
Messages
31
@CJ_London: Very nice. This article may be of interest to you in trying to handle continuous forms with scrolling. The "deprecated" function that I show in the article included code to identify the current position of the scroll bar so that I could restore that position following a form requery. I think you could apply the same concept to solve the issue you are running into. Whether it's worth the effort to do that, though, is a different question.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:57
Joined
Feb 19, 2013
Messages
16,612
Thanks Mike, I quickly tried the recordset.requery method but it introduces flicker. It may be I need to adjust something else :). I'll investigate further when I get a bit more time! The forms do use the absoluteposition value.

Arnelgp has an alternative method, utilising a more complex recordset bound to controls which works in a continuous form, but still suffers from flicker - been a bit of discussion about the differences here https://www.access-programmers.co.uk/forums/threads/modern-controls-on-off-switch.324510/
 

xavier.batlle

New member
Local time
Today, 11:57
Joined
Sep 1, 2023
Messages
21
Hi @CJ_London,
This is my approach to the topic and my first post.
After many years looking for a solution, I think I found and easy way to do it!
I've attached a database with an example using an On/Off image and a tri-state image in a continuous form and a transparent button over them.
The easier the better.
ContinuousForm.png
 

Attachments

  • ContinuousOnOff_Xevi .accdb
    580 KB · Views: 119
Last edited:

Users who are viewing this thread

Top Bottom