Go Back   Access World Forums > Microsoft Access Reference > Code Repository

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-26-2019, 09:15 AM   #1
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,905
Thanks: 40
Thanked 3,538 Times in 3,419 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
use a textbox as a resizeable and colourful checkbox

For whatever reason, checkbox controls cannot be resized. This suggestion addresses that issue and also enables the use of colour.



To create, put the following in the format property of a textbox and set the control source to a boolean value

1. set format property - [Blue]\R;[Green]\R;[Red]\S;
2. set font - wingdings 2
3. set font size as required - suggest 16 if normal font size is ll
4. set border to transparent
5. set enabled=no
6. set locked=yes
7. set tab stop to No

note enabled=no and locked=no will 'grey out' the control so colours are removed.

sometimes you might want null or false to be represented by an empty square box in which case change the S or in the format string to (chr163)

I've included a 'blue tick' because any number other than 0 is 'true' and you might want to differentiate between -1 and another value such as a count.

if the underlying field is required to be updateable then set enabled=true and in the onclick event put

Code:
if not mycontrol.locked then mycontrol=not nz(mycontrol,false)
locked only prevents users from manually entering data, not changes made by clicking

However this creates a presentational issue as the control now has the focus and will be trying to display the actual underlying value, so we need to move the focus elsewhere. You may have a control you can move it to. If not, create an unbound textbox called say 'txtFocus' and set top, left, width and height properties to 0. Then modify the control click event to

Code:
txtFocus.setfocus
if not mycontrol.locked then mycontrol=not nz(mycontrol,false)
Finally, you may have an issue that the control receives the focus when the form opens. If so, change the tab order so another control receives the initial focus - or create the txtFocus control, set the tab index to 0 and tab stop to yes

Edit: For a more system-wide solution, providing you are prepared to have the txtFocusControl on the form, the click event code can be put in a module

Code:
Function chkBoxChange()

    If Not Screen.ActiveControl.Locked Then Screen.ActiveControl = Not Nz(Screen.ActiveControl, False)
    Screen.ActiveControl.Parent.txtFocus.SetFocus
    
End Function
and then called by putting =chkBoxChange() against the click event (replacing [Event Procedure])
Attached Images
File Type: jpg Capture.JPG (10.1 KB, 150 views)

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button

Last edited by CJ_London; 06-26-2019 at 02:18 PM.
CJ_London is offline   Reply With Quote
The Following 3 Users Say Thank You to CJ_London For This Useful Post:
fhsmith (07-18-2019), Minty (06-26-2019), Tera (06-26-2019)
Old 06-26-2019, 10:27 AM   #2
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 1,863
Thanks: 17
Thanked 352 Times in 349 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: use a textbox as a resizeable and colourful checkbox

Please note, for most fonts and ASCII 251 will work just fine for a check...√
Mark_ is offline   Reply With Quote
The Following User Says Thank You to Mark_ For This Useful Post:
Tera (06-26-2019)
Old 06-26-2019, 10:40 AM   #3
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Posts: 1,956
Thanks: 0
Thanked 462 Times in 458 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: use a textbox as a resizeable and colourful checkbox

Nice. I wonder if something similar could be done with radio buttons in option group.

Couple minor typos:

other that 0

system-wide solution

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 06-26-2019, 12:57 PM   #4
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 10,081
Thanks: 476
Thanked 893 Times in 848 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: use a textbox as a resizeable and colourful checkbox

Quote:
Originally Posted by June7 View Post
Nice. I wonder if something similar could be done with radio buttons in option group.
It's funny you should mention that June! It's something I'm currently working on, I thought I had finished it, but then I found some issues which I wasn't happy with. I haven't got around to sorting out these issues yet so I haven't published it.

Simulated Option Group - Nifty Access
https://youtu.be/6aHoeOG1f2Q


Simulated Option Group Setup 1 - Nifty Access
https://youtu.be/k1GTGiQOsOA


Simulated Option Group Setup 2 - Nifty Access
https://youtu.be/pA_n5TF2QV8
__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|                                     |
|                                     |
| Get $20 worth of "Nifty Code"       |
|      
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)
Uncle Gizmo is offline   Reply With Quote
The Following User Says Thank You to Uncle Gizmo For This Useful Post:
Tera (06-26-2019)
Old 06-26-2019, 01:15 PM   #5
Micron
Newly Registered User
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 720
Thanks: 3
Thanked 148 Times in 142 Posts
Micron will become famous soon enough Micron will become famous soon enough
Re: use a textbox as a resizeable and colourful checkbox

Quote:
Originally Posted by June7 View Post
Nice. I wonder if something similar could be done with radio buttons in option group.
I would think you'd need an image control for each option if you want circular radio buttons. Have thought of using images along these lines but never got around to trying anything.
__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is online now   Reply With Quote
Old 06-26-2019, 02:04 PM   #6
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,905
Thanks: 40
Thanked 3,538 Times in 3,419 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: use a textbox as a resizeable and colourful checkbox

for radio buttons

false - chr153 -
true - chr158 -
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
Tera (06-26-2019)
Old 06-26-2019, 02:17 PM   #7
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,905
Thanks: 40
Thanked 3,538 Times in 3,419 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: use a textbox as a resizeable and colourful checkbox

for faces, use wingdings font

happy chr74 J
straight chr75 K
sad chr76 L

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 06-26-2019, 02:30 PM   #8
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,905
Thanks: 40
Thanked 3,538 Times in 3,419 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: use a textbox as a resizeable and colourful checkbox

Quote:
I wonder if something similar could be done with radio buttons in option group.
not using this method per se with the wizard since the options can only be option/check/toggle controls. But you could still build your own with additional code behind to switch the selection.
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 06-26-2019, 03:06 PM   #9
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,307
Thanks: 153
Thanked 1,690 Times in 1,662 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: use a textbox as a resizeable and colourful checkbox

Very neat, thank you for posting it.

I fiddled around with Windings ages ago to look at a solution for this issue, but time evaporated and I forgot all about it.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 06-26-2019, 08:46 PM   #10
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,547
Thanks: 88
Thanked 1,473 Times in 1,390 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: use a textbox as a resizeable and colourful checkbox

Quote:
Originally Posted by CJ_London View Post
For whatever reason, checkbox controls cannot be resized. This suggestion addresses that issue and also enables the use of colour.
I implemented a similar idea as a Class a few years ago. I intended to get it fully developed and post it but it dropped below the radar and I forgot about it until I just saw this thread.

The Class simplified the setup a lot and easily supports multiple instances. Each instance is completely configured by simply nominating a Textbox and a button that work together to simulate the checkbox. The transparent button simulates a label to precisely emulate the behavior of checkbox labels.

ConditonalFormatting for enabling is supported and also allowed them to work in ContinuousForms. Currently the instance also needs any controls involved in the ConditionalFormat nominated so that it can define the update events that it needs to respond to.

I was working on having the class parse the format conditions so it didn't need the other controls nominated and a collection that could set up and handle events relevant to the simulated checkbox.

I'll get back onto it sometime soon and post here.
Galaxiom is offline   Reply With Quote
Old 06-27-2019, 12:32 AM   #11
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,905
Thanks: 40
Thanked 3,538 Times in 3,419 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: use a textbox as a resizeable and colourful checkbox

I'm glad people are finding it of interest. I'm just working on a 'dropdown' continuous form for listing fields in a query for users to select which fields they want to search on (or display) - looks a bit like the dropdown for a multivalue combo box - to replace a multiselect listbox I've been using up until now.

I developed the functionality because I wanted a control which was 'finger sized' for touch screen applications and used the underlying value rather than needing code. I previously demoed a multiselect form which is in sample databases so this is really just an extension of that principle.

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
fhsmith (07-18-2019)
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Colourful query isladogs Queries 13 01-15-2018 10:15 AM
create a colourful clickable schedule shutzy Forms 7 04-03-2012 12:52 AM
Enabling TextBox upon changes in CheckBox w.rizky Forms 6 11-30-2009 12:14 AM
Show textbox when checkbox checked mickelingon Forms 2 02-08-2006 05:14 AM
link checkbox to textbox jrmywvr Modules & VBA 1 02-07-2003 04:40 PM




All times are GMT -8. The time now is 09:13 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World