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

 
Closed Thread
 
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: 11,330
Thanks: 40
Thanked 3,669 Times in 3,537 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
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, 296 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 online now  
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: 2,032
Thanks: 20
Thanked 381 Times in 374 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  
The Following 2 Users Say Thank You to Mark_ For This Useful Post:
fhsmith (07-25-2019), Tera (06-26-2019)
Old 06-26-2019, 10:40 AM   #3
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,403
Thanks: 0
Thanked 559 Times in 555 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  
The Following User Says Thank You to June7 For This Useful Post:
fhsmith (07-25-2019)
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,307
Thanks: 534
Thanked 937 Times in 888 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  
The Following 2 Users Say Thank You to Uncle Gizmo For This Useful Post:
fhsmith (07-25-2019), Tera (06-26-2019)
Old 06-26-2019, 01:15 PM   #5
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 1,050
Thanks: 10
Thanked 208 Times in 197 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
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 offline  
The Following User Says Thank You to Micron For This Useful Post:
fhsmith (07-25-2019)
Old 06-26-2019, 02:04 PM   #6
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,669 Times in 3,537 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
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 online now  
The Following 2 Users Say Thank You to CJ_London For This Useful Post:
fhsmith (07-25-2019), Tera (06-26-2019)
Old 06-26-2019, 02:17 PM   #7
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,669 Times in 3,537 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
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 online now  
The Following User Says Thank You to CJ_London For This Useful Post:
fhsmith (07-25-2019)
Old 06-26-2019, 02:30 PM   #8
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,669 Times in 3,537 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
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 online now  
The Following User Says Thank You to CJ_London For This Useful Post:
fhsmith (07-25-2019)
Old 06-26-2019, 03:06 PM   #9
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,432
Thanks: 165
Thanked 1,736 Times in 1,706 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  
The Following User Says Thank You to Minty For This Useful Post:
fhsmith (07-25-2019)
Old 06-26-2019, 08:46 PM   #10
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,651
Thanks: 98
Thanked 1,499 Times in 1,414 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  
The Following User Says Thank You to Galaxiom For This Useful Post:
fhsmith (07-25-2019)
Old 06-27-2019, 12:32 AM   #11
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,669 Times in 3,537 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
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 online now  
The Following User Says Thank You to CJ_London For This Useful Post:
fhsmith (07-18-2019)
Old 07-18-2019, 12:12 PM   #12
fhsmith
Newly Registered User
 
Join Date: Jul 2019
Posts: 11
Thanks: 24
Thanked 0 Times in 0 Posts
fhsmith is on a distinguished road
Re: use a textbox as a resizeable and colourful checkbox

Thanks for the tips. I tried the checkbox resize workaround but have problems. I am using access 2002.

I want to expand the size of the check box on a yes/no field placed on a form. The yes/no boxes are too small. I can not get the text box to update the yes/no field in the main table. How do I do this? Many thanks for your assistance.
fhsmith is offline  
Old 07-21-2019, 12:30 PM   #13
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,956
Thanks: 114
Thanked 2,993 Times in 2,721 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: use a textbox as a resizeable and colourful checkbox

@fhsmith
This is a moderated area. Please see the sticky thread about reporting your own post.

I've not tested CJL's code in A2002 but its a very old version of Access and not all functionality may be available in that version.

If you want more specific help to your issue, I suggest you create a new thread, post the relevant code and describe what happened plus any error messages. Include a link back to this thread.

Thanks

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
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.
,
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.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
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.
isladogs is offline  
The Following User Says Thank You to isladogs For This Useful Post:
fhsmith (07-25-2019)
Closed Thread

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 10:30 AM.


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